From 470607cae1ff722a30ece7ac698ef4115d8e7074 Mon Sep 17 00:00:00 2001 From: alex-delia Date: Thu, 9 Oct 2025 21:41:49 -0400 Subject: [PATCH] update search params guide for zod 3.24.0+ --- .../framework/react/guide/search-params.md | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/router/framework/react/guide/search-params.md b/docs/router/framework/react/guide/search-params.md index dec18506718..4879428d96e 100644 --- a/docs/router/framework/react/guide/search-params.md +++ b/docs/router/framework/react/guide/search-params.md @@ -203,7 +203,27 @@ For validation libraries we recommend using adapters which infer the correct `in ### Zod -An adapter is provided for [Zod](https://zod.dev/) which will pipe through the correct `input` type and `output` type +> [!WARNING] +> Router expects the zod 3.24.0+ package to be installed to use without an adapter. + +When using [Zod](https://zod.dev/) 3.24.0+ an adapter is not needed to ensure the correct `input` and `output` types are used for navigation and reading search params. This is because [Zod](https://zod.dev/) implements [Standard Schema](https://github.com/standard-schema/standard-schema) + +```tsx +import { createFileRoute } from '@tanstack/react-router' +import { z } from 'zod' + +const productSearchSchema = z.object({ + page: z.number().default(1).catch(1), + filter: z.string().default('').catch(''), + sort: z.enum(['newest', 'oldest', 'price']).default('newest').catch('newest'), +}) + +export const Route = createFileRoute('/shop/products/')({ + validateSearch: productSearchSchema, +}) +``` + +For [Zod](https://zod.dev/) <3.24.0 an adapter is provided which will pipe through the correct `input` type and `output` type ```tsx import { createFileRoute } from '@tanstack/react-router'