Skip to content

feat: Add Standard Schema interface#965

Merged
franky47 merged 20 commits intonextfrom
feat/standard-schema
Jun 27, 2025
Merged

feat: Add Standard Schema interface#965
franky47 merged 20 commits intonextfrom
feat/standard-schema

Conversation

@franky47
Copy link
Member

@franky47 franky47 commented Apr 6, 2025

This adds a new export, createStandardSchemaV1, which (as the name implies), creates a standard-schema compatible object that can be fed to tRPC's inputs, or TanStack Router for search params validation (see #953).

image

Since nuqs parsers always assume they have to deal with deserialisation, and those validation libraries generally assume they work with data already of the right shape (kind of) and verify runtime constraints, we first run the input through the serializer to generate a URL, which we can then parse.

This also introduces a new option on the loaders & the cache: strict mode, which will throw errors rather than applying default values (or returning null) for invalid querystring values.

It also fixes a bug where the loader functions had a signature mismatching the runtime implementation: passing urlKeys is only supported when creating the loader function, which now can accept a different set of runtime options like strict mode. We're renaming the types to make this clearer.

It also deprecates parseServerSide for parsers, as it was an internal artefact of resolving a non-nullable type when specifying a default value. Loaders now have integrated parseServerSide's duties and do provide stronger key/value type-safety (while also supporting other things like strict mode and urlKeys).

Tasks

  • Add tests
  • Add example with tRPC
  • Add docs
  • Add loader strict mode, docs & tests
  • Add cache strict mode, docs & tests
  • Test equality of input/output in the SSv1 validate method ?

@franky47 franky47 added the feature New feature or request label Apr 6, 2025
@franky47 franky47 added this to the 🪵 Backlog milestone Apr 6, 2025
@vercel
Copy link

vercel bot commented Apr 6, 2025

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 Jun 27, 2025 6:37am

@pkg-pr-new
Copy link

pkg-pr-new bot commented Apr 6, 2025

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

commit: 7769705

@franky47 franky47 marked this pull request as draft April 6, 2025 10:29
@franky47 franky47 force-pushed the feat/standard-schema branch from ca05aac to 748d789 Compare April 7, 2025 20:37
@franky47 franky47 force-pushed the feat/standard-schema branch 2 times, most recently from 2cad8bf to 70f9ed7 Compare April 11, 2025 18:37
@franky47 franky47 force-pushed the feat/standard-schema branch from 70f9ed7 to 7162ec8 Compare April 17, 2025 08:01
@franky47 franky47 force-pushed the feat/standard-schema branch from 085449e to ada6de0 Compare April 23, 2025 12:24
@franky47 franky47 force-pushed the feat/standard-schema branch from ada6de0 to 739faf1 Compare June 10, 2025 09:16
@socket-security
Copy link

socket-security bot commented Jun 10, 2025

@franky47 franky47 force-pushed the feat/standard-schema branch from 30f4397 to 7769705 Compare June 27, 2025 06:34
@franky47 franky47 enabled auto-merge (squash) June 27, 2025 06:34
@franky47 franky47 merged commit b929682 into next Jun 27, 2025
25 checks passed
@franky47 franky47 deleted the feat/standard-schema branch June 27, 2025 06:37
@github-actions
Copy link

🎉 This PR is included in version 2.5.0-beta.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 2.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@franky47 franky47 removed this from the 🚀 Shipping next milestone Aug 22, 2025
@franky47 franky47 mentioned this pull request Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant