Giter VIP home page Giter VIP logo

Comments (7)

saltyshiomix avatar saltyshiomix commented on August 17, 2024 2

@rafaelugolini

Good question.
As you pointed out, nextron's structure is not equal to now-desktop one.

The now-desktop defines routes in main process like this:

https://github.com/zeit/now-desktop/blob/canary/main/index.js#L178

const windows = {
  main: mainWindow(tray),
  tutorial: tutorialWindow(tray),
  about: aboutWindow(tray)
}

// Make the window instances accessible from everywhere
global.windows = windows

And accesses routes from renderer process like this:

https://github.com/zeit/now-desktop/blob/canary/renderer/pages/about.js#L127

const windows = this.remote.getGlobal('windows')

windows.tutorial.show()

Because electron in production mode (binary) can handle only static files for security reasons, we need get routes by accessing main process. (ex: ipc communication, electron.remote and so on)

Here is an example code that shows a difference between dev and prod mode in electron:

https://github.com/zeit/now-desktop/blob/canary/main/index.js#L178

const loadPage = (win, page) => {
  if (isDev) {
    win.loadURL(`http://localhost:8000/${page}`)
  } else {
    win.loadFile(`${electron.app.getAppPath()}/renderer/out/${page}/index.html`)
  }
}

Nextron's one:

https://github.com/saltyshiomix/nextron/blob/master/examples/_template/js/main/background.js#L20

if (isProd) {
  const homeFile = join(app.getAppPath(), 'app/home/index.html')
  mainWindow.loadFile(homeFile)
} else {
  const homeUrl = 'http://localhost:8888/home'
  mainWindow.loadURL(homeUrl)
  mainWindow.webContents.openDevTools()
}

In conclusion, though I want to implement pretty routing, we need to handle routes both dev and prod mode.

So I think <Link prefetch> works only development mode.

I want help, too. I'm sorry not helps.

from nextron.

rafaelugolini avatar rafaelugolini commented on August 17, 2024 1

@saltyshiomix I just tested using <Link href="..." prefetch>...</Link> and you can feel the links happening faster.
https://nextjs.org/docs/#prefetching-pages

Also worth investigating static export for production, right?
https://nextjs.org/docs/#static-html-export

Do you want help with this? Maybe I can create a PR about it.

from nextron.

saltyshiomix avatar saltyshiomix commented on August 17, 2024

Hi @rafaelugolini , thank you for your question :)

There is no performance issues for now, but best performance is SPA in renderer process so I mention it.
(Next.js is a SSR framework and is not supported SPA. I'm looking for SPA techniques with Next.js, too.)

from nextron.

saltyshiomix avatar saltyshiomix commented on August 17, 2024

@rafaelugolini

PRs are so much welcome 🥇

But please make sure that the electron in production mode can handle only static files so the url changes comparing to development mode.
I'm not sure prefetching-pages works when production mode :(

Nextron resolve these problems by ipc communication when facing difficulties.

For more information:

main process: resolveWithIpc()
https://github.com/saltyshiomix/nextron/blob/master/examples/_template/ts/main/helpers/resolveWithIpc.ts

renderer process: resolveWithIpc()
https://github.com/saltyshiomix/nextron/blob/master/examples/_template/ts/renderer/helpers/resolveWithIpc.ts

Digging deeper: ipc communication example:

$ nextron init test-app --template ipc-communication

from nextron.

rafaelugolini avatar rafaelugolini commented on August 17, 2024

@saltyshiomix I was looking at some projects (e.g., https://github.com/zeit/now-desktop), and they use routes to separate windows (about, feed, ...)

Maybe it's a matter on how to organize the app and not depend on next.js routes?

Do you have any ideas how to solve this?

from nextron.

saltyshiomix avatar saltyshiomix commented on August 17, 2024

@rafaelugolini

I found it:
https://github.com/GoogleChromeLabs/quicklink

It says:

Todo: Explore detecting file-extension of resources and using rel=preload for high priority fetches

It may be some helps.

from nextron.

saltyshiomix avatar saltyshiomix commented on August 17, 2024

There are no critical performance issues for one year, so I think it's time for closing this issue.

from nextron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.