Skip to content

Nextjs page router import error #1112

@spotsccc

Description

@spotsccc

Context

What's your version of nuqs?
2.5.2

What framework are you using?

✅/Next.js (pages router)

Which version of your framework are you using?
15.1.5

Description

When using nuqs in a Next.js project with Pages Router (/pages/...), importing hooks like useQueryState causes a crash in development mode:

Error: require() of ES Module /node_modules/nuqs/dist/index.js from /.next/server/pages/... not supported.
Instead change the require of index.js to a dynamic import() which is available in all

There is no errors in production build

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcannot-reproduceEither no reproduction provided, or cannot reproduce with a minimal setup

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions