Problem migrating from App Router to Pages Router
Unanswered
Tramp ant posted this in #help-forum
Tramp antOP
I'm migrating from App Router to Pages Router (because I'm building an Electron app, and it seems App Router is not well supported - the Next.js Electron examples are all Pages Router, for example.)
I've moved all my routes to /pages, however it still seems to be trying to use the App Router. I've tried clearing .next and node_modules. I'm using Next.js 14.1.4.
Apparently it's no longer possible to disable App Router by setting appDir to false in next.config.js. I'm not sure what else would cause it to try to use the App Router.
I've moved all my routes to /pages, however it still seems to be trying to use the App Router. I've tried clearing .next and node_modules. I'm using Next.js 14.1.4.
Apparently it's no longer possible to disable App Router by setting appDir to false in next.config.js. I'm not sure what else would cause it to try to use the App Router.
./node_modules/next/dist/client/components/react-dev-overlay/internal/helpers/use-websocket.js:86:8
Module not found: Can't resolve '@vercel/turbopack-ecmascript-runtime/dev/client/hmr-client.ts'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./node_modules/next/dist/client/components/react-dev-overlay/hot-reloader-client.js
./node_modules/next/dist/client/components/app-router.js
./node_modules/next/dist/client/app-call-server.js
./node_modules/next/dist/build/webpack/loaders/next-flight-loader/action-client-wrapper.js
./lib/dbFetch.ts
./pages/page/EditingArea.tsx
./pages/page/index.tsx16 Replies
Pages router is not a good option.
I'd recommend you to make a electron app seperately from scratch.
I don't think you'll get any help here, as its a uncommon approach
I'd recommend you to make a electron app seperately from scratch.
I don't think you'll get any help here, as its a uncommon approach
Tramp antOP
Why is pages router not a good option?
The Next.js team provides official Electron app examples. Seems to work fine.
The Next.js team provides official Electron app examples. Seems to work fine.
Netherland Dwarf
Its because app router supports newer react features while page router may not support them
Also app router makes a lot of things easier compared to page router and has more optimal performance by a lot compared to page router
Netherland Dwarf
For example the Link component and less hydration improves SEO performance and UX experience
Compared to page router which does not have these features
So if your app is doing fine now or doesnt need further optimal performance then its fine to keep it with page router, otherwise switching to app will help a lot.
Tramp antOP
I am actually switching the other way, to Pages Router, because that is what Next.js recommends for Electron apps. Also, I have a SPA, so I don't think performance will be impacted much.
My issue though is that even though I no longer have an /app directory, Next.js is still trying to use App Router, and I can't figure out why.
My issue though is that even though I no longer have an /app directory, Next.js is still trying to use App Router, and I can't figure out why.
Asian black bear
Try shutting down the dev server and deleting the .next folder which has a lot of cached stuff in there to see if it gets any better.
To the others in the thread: please think about what you're responding, especially if you don't have an understanding what it's all about. With an Electron app many things become unnecessary and blanket statements of "use X instead" over actually helping the people in question are completely unnecessary.
Also OP: keep in mind that Next, unless you export the application as a standalone prebuilt bundle without requiring a server, requires a running Node instance otherwise which can become tricky to embed into Electron at which point you should evaluate if it's not just easier to spin up a Vite-based SPA that Electron can host.
Tramp antOP
Yeah, this app will be available both as a "pure" webapp and as an Electron app (which will hit the same backend as the webapp.) The Next.js experience was very nice for building the webapp, and I'd prefer not to maintain two codebases. But it does seem like I'm swimming against the current here.
@Asian black bear Try shutting down the dev server and deleting the .next folder which has a lot of cached stuff in there to see if it gets any better.
Tramp antOP
Yeah, I did try shutting down the dev server, clearing out .next + node_modules/ and then restarting. No dice.
Asian black bear
It is possible to export the Next app in standalone mode where the server-capabilities aren't available anymore.
@Tramp ant Yeah, I did try shutting down the dev server, clearing out .next + node_modules/ and then restarting. No dice.
Asian black bear
Then you probably have to create a fresh Next project for testing purposes to confirm whether this is a general Next issue or related to your own codebase. If it's the latter apply bisection to your code until you get it running by deleting half of your code in every iteration to see if the error still occurs.
Tramp antOP
Okay, thanks.