Navigation not working on electron.js + next.js
See original GitHub issueBug report
Describe the bug
When trying to navigate to a different page using next.js+ typescript + electron the click over the link does nothing
To Reproduce
- Download next.js with-electron-typescript example https://github.com/vercel/next.js/tree/canary/examples/with-electron-typescript
- Install modules:
with-electron-typescript$ yarn
- Pack app:
with-electron-typescript$ yarn pack-app
- Go to with-electron-typescript/dist/win-unpacked
- Execute (double click) ElectronTypescriptNext.exe
- Try to navigate to Home, About and With Initial Props
Expected behavior
The application should navigate to the specified page:
Click on home – navigate to --> pages/home Click on about – navigate to --> pages/about …and so on.
Screenshots
The links seems to be rendered properly, linking to file:///
the src of the scripts is /_next/...
(file:///_next/…)
But if I go to Sources tab then it shows that the _next/
resources are under C://
Shouldn’t the scripts’ src in the first picture link to /C://_next/...
instead of /_next/...
to get file:///C:/_next/...
?
System information
- OS: Windows 10
- Version of Electron.js: 7.1.7
- Version of Next.js: 9.5.2 (latest)
- Version of Node.js: 12.16.2
- Version of yarn: 1.15.2
Additional context
- I tried using
<base href="./" />
but it does not solve the routing issue because base tag does not work with absolute paths (like /about, /_next/) but with relative ones (./about, ./_next/) - next.config.js basePath does not allow relative paths, so you cannot do
basePath: './'
to transform/about --> ./about
- Even tried with the “import empty css” hack https://github.com/vercel/next.js/issues/5203#issuecomment-423403716
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Electron app with Nex.js (loading html files not working)
I can see the files generated by electron-builder and nowhere I can find the static html files. Is there something I'm missing? Are...
Read more >Routing: Linking and Navigating - Next.js beta docs
Learn how to use the Link Component, useRouter Hook, and navigate between routes in your Next.js application.
Read more >Building an app with Next.js and Electron - LogRocket Blog
Use Nextron to create a desktop application and features such as new pages, application layouts, new windows, and executable files.
Read more >Security | Electron
It is paramount that you do not enable Node.js integration in any renderer ( BrowserWindow ... For example, if you are opening a...
Read more >Tutorial: Create a Node.js and React app in Visual Studio
Learn how to create a Node.js web application project from a Visual ... Set and hit a breakpoint in the client-side React code;...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As in #16456, downgrading to next@9.5.1 worked for me.
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.