47ng / nuqs

Type-safe search params state manager for React frameworks - Like useState, but stored in the URL query string.
https://nuqs.47ng.com
MIT License
3.97k stars 80 forks source link

Does not work with pages only router (next/useRouter) #591

Closed jhensley closed 1 week ago

jhensley commented 2 months ago

Context

What's your version of nuqs?

"nuqs": "^1.17.4",

-> Paste result from `cat package.json | grep -e nuqs -e next-usequerystate` here

Next.js information (obtained by running next info):

-> Paste result from `next info` here

Are you using:

Description

When exclusively using pages router, Next throws an error due to AppRouterContext being null. See: https://github.com/vercel/next.js/blob/44bac5100d0ae6afef2925c3d88810c63eaf3eba/packages/next/src/client/components/navigation.ts#L117

Reproduction

... Will work on it

jhensley commented 2 months ago

I've seen other threads referencing an import specific for pages routers (i.e. import { useQueryState } from 'nuqs/pages') -- seems like an ideal solution.

franky47 commented 2 months ago

What's your Next.js version?

jhensley commented 2 months ago

What's your Next.js version?

14.2.1

franky47 commented 2 months ago

I was not able to get this error with a minimal reproduction repo (source here).

Could there be something else in your application setup causing this error?

franky47 commented 1 week ago

Going to close this issue, feel free to reopen it with a link to a reproduction repository.