-
Is it possible to use the Next.js pages router with next-usequerystate v1.8.0-beta.12? I'm using Next 13.4.19 and get the following error when error Error [ERR_MODULE_NOT_FOUND]:
Cannot find module '/path/to/project/node_modules/next/navigation'
imported from /path/to/project/node_modules/next-usequerystate/dist/index.js |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Thanks for your report, it looks like this can be fixed by importing from Related issues on Next.js: |
Beta Was this translation helpful? Give feedback.
-
@franky47 My setup is Next.js 14 + tRPC (which runs some SSR prepasses with a corresponding attribute on). It happens because there are two different contexts - one from "next/navigation" (the one that actually exists in scope) and one from "next/navigation.js" (the one expected by hook in To illustrate this example, I wrote this code in my custom hook: import { useRouter } from "next/navigation";
import { useRouter as useRouterJs } from "next/navigation.js";
console.log("Are the same?", useRouterJs === useRouter); // false server-side, true client-side My Node.js debugger links those functions to different instances of I suspect something's happening around the bundle. My current (temporary) solution is to patch the library and pass my own |
Beta Was this translation helpful? Give feedback.
Thanks for your report, it looks like this can be fixed by importing from
next/navigation.js
in library code (for some reason importing without the extension works in app code).1.8.0-beta.13
includes this change, can you try it to see if it fixes your issue?Related issues on Next.js: