question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Navigation not working on electron.js + next.js

See original GitHub issue

Bug 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

  1. Download next.js with-electron-typescript example https://github.com/vercel/next.js/tree/canary/examples/with-electron-typescript
  2. Install modules: with-electron-typescript$ yarn
  3. Pack app: with-electron-typescript$ yarn pack-app
  4. Go to with-electron-typescript/dist/win-unpacked
  5. Execute (double click) ElectronTypescriptNext.exe
  6. 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:/// image

the src of the scripts is /_next/... (file:///_next/…) image

But if I go to Sources tab then it shows that the _next/ resources are under C:// image

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

  1. 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/)
  2. next.config.js basePath does not allow relative paths, so you cannot do basePath: './' to transform /about --> ./about
  3. Even tried with the “import empty css” hack https://github.com/vercel/next.js/issues/5203#issuecomment-423403716

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jambuludcommented, Aug 27, 2020

As in #16456, downgrading to next@9.5.1 worked for me.

0reactions
balazsorban44commented, Jan 27, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found