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

fix: Handle Promises for the searchParams page prop #652

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

franky47
Copy link
Member

Next.js 15.0.0-canary-171 introduced a breaking change in vercel/next.js#68812 causing the searchParam page prop to be a Promise.

Using overloads, the cache.parse function can now handle either, but typing the searchParams page prop in userland is becoming painful if support for both Next.js 14 and 15 is desired.

Best approach is to always declare it as a Promise (with SearchParams imported from 'nuqs/server'), as it highlights the need to await the result of the parser, and doesn't cause runtime issues if the underlyign type is a plain object (the await becomes a no-op).

Next.js 15.0.0-canary-171 introduced a breaking change in
vercel/next.js#68812
causing the searchParam page prop to be a Promise.

Using overloads, the cache.parse function can now handle either,
but typing the searchParams page prop in userland is becoming
painful if support for both Next.js 14 and 15 is desired.

Best approach is to always declare it as a Promise<SearchParams>
(with `SearchParams` imported from 'nuqs/server'), as it highlights
the need to await the result of the parser, and doesn't cause runtime
issues if the underlyign type is a plain object (the await becomes a no-op).
Copy link

vercel bot commented Sep 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuqs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 26, 2024 8:15am

Copy link

pkg-pr-new bot commented Sep 26, 2024

Open in Stackblitz

pnpm add https://pkg.pr.new/nuqs@652

commit: 0296ae5

@franky47 franky47 marked this pull request as ready for review September 26, 2024 11:04
@franky47 franky47 merged commit 63d01eb into next Sep 26, 2024
21 checks passed
@franky47 franky47 deleted the fix/search-params-page-prop-promise branch September 26, 2024 11:04
Copy link

🎉 This PR is included in version 1.19.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant