Back to journals
Loading article…
Journals
Short notes and snippets — too brief for a full blog post, worth writing down.
Back to journals
Back to journals
TIL
Coerce and validate URL search state in the route definition — not scattered in components.
Date published
## Search schema at the route boundary
```ts
const searchSchema = z.object({
page: z.coerce.number().int().min(1).optional(),
});
export const Route = createFileRoute("/lessons/")({
validateSearch: (search) => searchSchema.parse(search),
});
```
Invalid URLs get normalized before any component renders.