47ng/nuqs

global variable `next` does not exist in storybook

bestLessons opened this issue · 3 comments

Context

What's your version of nuqs?

"nuqs": "^1.15.3",

next@13.5.6

Are you using:

  • ✅ The app router
  • ✅ The pages router
  • ❌ The basePath option in your Next.js config
  • ❌ The experimental windowHistorySupport flag in your Next.js config

Description

While running storybook useQueryState has a line window.next.version !== '14.0.3' -> which assumes that there is a global next variable inside storybook. But it doesn't exist.

I think it'd be better to add something like window.next?.version just to make it work by default

Reproduction

Steps to reproduce the behavior:

  1. Setup any storybook with a component that uses import { useQueryState } from 'nuqs'; and it will fail to render

Facing this as well -> true in test environments.

I recommend you update your types to make next optional on the window to avoid such errors in future:

Thanks, I had fixed it in a previous place but this one slipped through. Types updated, marked as optional, and release baking in the oven.

🎉 This issue has been resolved in version 1.15.4 🎉

The release is available on:

Your semantic-release bot 📦🚀