Comments (7)
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.
@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.
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.
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.
@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.
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.
There are no critical performance issues for one year, so I think it's time for closing this issue.
from nextron.
Related Issues (20)
- Documentation on code signing for OSX? HOT 1
- when app router version is scheduled to be released HOT 4
- Node modules not installed? HOT 2
- Command failed with UNKNOWN: next -p 8888 renderer
- `.gitignore` in Root Directory Ignores Nested `app` Directories Unnecessarily HOT 1
- react-focus-lock Why can't I install this? HOT 1
- Electron process ignores config value HOT 1
- install directly with app router? HOT 2
- Command line arguments not working in dev command HOT 1
- Electron updater HOT 9
- ESM: latest sindresorhus packages support HOT 3
- IPC example HOT 14
- i18next Localization of dynamic pages does not work in the build HOT 2
- Nextron Tailwind Example does not work with `pnpm` HOT 2
- Vercel backend SSR / server actions HOT 1
- How to remove window.ipc.on listener? HOT 1
- cat not start debugger port
- error: unknown option '-o' HOT 12
- remote debugging HOT 1
- Nextron v9 with next js 14.2.4 white window in prod build with page router and electron 31 HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nextron.