Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion docs/router/framework/react/guide/search-params.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Loading