storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.82k stars 9.34k forks source link

[Bug]: next-usequerystate/nuqs "invariant expected app router to be mounted" #25612

Closed isBatak closed 10 months ago

isBatak commented 10 months ago

Describe the bug

next-usequerystate/nuqs lib is using next/navigation and it can be used in both app and pages folder. https://github.com/47ng/nuqs/blob/f0f6de78950e0dca987d94533b99ebb8f745f4e9/packages/nuqs/src/useQueryState.ts#L1

Components that uses useQueryState inside pages folder are not working in storybook.

image

To Reproduce

CodeSandbox Link

System

"next-usequerystate": "1.15.2"
"storybook": "7.6.8"
"@storybook/nextjs": "7.6.8"

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.1.0: Mon Oct  9 21:28:45 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6020
Binaries:
  Node: 20.10.0
  npm: 10.2.3
  Yarn: 3.2.3
  pnpm: 8.6.12
Relevant Packages:
  next: 14.0.4
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

Additional context

Related issue on next-usequerystate repo https://github.com/47ng/nuqs/issues/460

shilman commented 10 months ago

closing as dupe to #24722