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

feat: Add temporary dedicated server features imports #805

Open
wants to merge 3 commits into
base: next
Choose a base branch
from

Conversation

franky47
Copy link
Member

@franky47 franky47 commented Dec 12, 2024

This allows using the serializer and the parsers in server-side code without depending on React for the cache, as would be the case if importing from nuqs/server.

🦋 https://bsky.app/profile/francoisbest.com/post/3ld5bqxov722z
X: https://x.com/nuqs47ng/status/1867331081349083400

Tasks

  • Update docs
  • Investigate import issues with moduleResolution

Note

This PR adds three new imports:

  • nuqs/server/cache: exports only the cache feature. Requires React canary (currently only useful in Next.js app router)
  • nuqs/server/parsers: exports defs & all built-in parsers
  • nuqs/server/serializer: exports defs & the createSerializer feature

The nuqs/server import is untouched in this PR.

Future breaking change plans

In nuqs v3:

  • nuqs/server/cache will be the only way to import the cache feature, it will be removed from nuqs/server
  • nuqs/server/parsers and nuqs/server/serializers may be removed for cleanup, as their code will be importable from nuqs/server in a framework-agnostic way.

Closes #804.
See also discussion #717.

Copy link

vercel bot commented Dec 12, 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 Dec 14, 2024 0:27am

@franky47 franky47 added this to the 🪵 Backlog milestone Dec 12, 2024
Copy link

pkg-pr-new bot commented Dec 12, 2024

Open in Stackblitz

npm i https://pkg.pr.new/nuqs@805

commit: 6afea91

This allows using the serializer and the parsers in server-side code without
depending on React for the cache, as would be the case if importing
from `nuqs/server`.

Closes #804. See also discussion #717.
For some reason, the classic trick of forwarding everything doesn't work under
`nuqs/server/*`.
We're also removing the temporary imports' `moduleResolution: 'node'` helpers,
as v3 will both remove them and require a moduleResolution set to either 'bundler' or 'nodeNext'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nuqs/server requires react
1 participant