Closed sunwrobert closed 10 months ago
Thanks for the report. The only change between 1.13.1 and 1.13.2 concerns the pages router, but you mention using the app router.
Could you fill up the context section of the issue template please, so I can try and reproduce? Including your storybook/vitest setup would also be very useful, thanks.
This "router is undefined" error (ignore the rate-limit message, that is a try-catch being placed too wide) could indicate that Storybook doesn't run in a Next.js context, which is needed for nuqs
to function.
Sure, will get a repro
@franky47 Added repro steps. I am using a custom mock router to get this to work, so the thing is that just that the error above throws in tests. I could try ignoring the error, but issue still stands that it'll cause my tests to fail in 1.13.2 but not 1.13.1
:tada: This issue has been resolved in version 1.15.2 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Thanks to your reproduction, I found the issue: nuqs
tries to detect whether it's running in the pages router vs app router with a check that was introduced in 1.13.2, but this check always assumed we were running in Next.js and could access its internals, which are not set in test/mock environments.
Let me know if 1.15.2 works for you.
Yup, it works. Thanks @franky47
Context
What's your version of
nuqs
? 1.13.2Next.js information (obtained by running
next info
):Are you using:
basePath
option in your Next.js configwindowHistorySupport
flag in your Next.js configDescription
Ever since I upgraded to nuqs 1.13.2, I get the following error in my vitest tests that use nuqs through Storybook. 1.13.1 works perfectly fine
Reproduction
npm install
->npm run test
The relevant test is
nuqs-demo.test.tsx
Notice that the error above throws.
If I downgrade to 1.13.1, it doesn't throw.