Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuqs not parsing on pasting the url #685

Closed
gajraj-gan opened this issue Oct 21, 2024 · 2 comments
Closed

Nuqs not parsing on pasting the url #685

gajraj-gan opened this issue Oct 21, 2024 · 2 comments
Labels
adapters/next/pages Uses the Next.js pages router bug Something isn't working cannot-reproduce Either no reproduction provided, or cannot reproduce with a minimal setup duplicate This issue or pull request already exists next.js Issue is related to Next.js internals rather than this library

Comments

@gajraj-gan
Copy link

Context

What's your version of nuqs?

"nuqs": "^1.17.6",

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

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:22 PDT 2022; root:xnu-8020.140.41~1/RELEASE_ARM64_T6000
Binaries:
  Node: 18.18.2
  npm: 9.8.1
  Yarn: 1.22.21
  pnpm: N/A
Relevant Packages:
  next: 13.5.4
  eslint-config-next: 13.4.1
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.2
Next.js Config:
  output: N/A

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

We are using the useQueryState to parse the state. When I redirect to the page from another page, the library parses it correctly but if I paste the url in a new tab -- the state is not parsed and returns the default value.

E.g.

http://localhost:4200/sound-effects?tab=history

If I redirect to this page tab="sometingelse" it works, but if I paste the url directly value of tab will not be history

@gajraj-gan gajraj-gan added the bug Something isn't working label Oct 21, 2024
@franky47
Copy link
Member

franky47 commented Oct 21, 2024

Could you show me a minimal reproduction example please?

One caveat with the pages router on initial navigation is that the URL elements (search params included) won't be available on the first render if it's a static page: Next will use an empty set of search params from when the pages was built, hydrate with this empty set (to avoid hydration errors) and then re-render with the available search params.

This isn't the case on subsequent navigations (with Links or redirects), which might explain what you are seeing.

See #290 for reference and possible actions.

@franky47 franky47 added duplicate This issue or pull request already exists next.js Issue is related to Next.js internals rather than this library adapters/next/pages Uses the Next.js pages router labels Oct 21, 2024
@franky47
Copy link
Member

franky47 commented Nov 1, 2024

Closing this for now, if still relevant please reopen with a reproduction repository.

@franky47 franky47 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 1, 2024
@franky47 franky47 added the cannot-reproduce Either no reproduction provided, or cannot reproduce with a minimal setup label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adapters/next/pages Uses the Next.js pages router bug Something isn't working cannot-reproduce Either no reproduction provided, or cannot reproduce with a minimal setup duplicate This issue or pull request already exists next.js Issue is related to Next.js internals rather than this library
Projects
None yet
Development

No branches or pull requests

2 participants