47ng / nuqs

Type-safe search params state manager for React frameworks - Like useState, but stored in the URL query string.
https://nuqs.47ng.com
MIT License
4.91k stars 105 forks source link

fix: Handle Promises for the searchParams page prop #652

Closed franky47 closed 2 months ago

franky47 commented 2 months ago

Next.js 15.0.0-canary-171 introduced a breaking change in https://github.com/vercel/next.js/pull/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).

vercel[bot] commented 2 months ago

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
pkg-pr-new[bot] commented 2 months ago

Open in Stackblitz

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

commit: 0296ae5

github-actions[bot] commented 2 months ago

:tada: This PR is included in version 1.19.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: