TanStackT
TanStack3mo ago
1 reply
worthy-azure

How do I make search params optional in navigate()?

Getting the attached error for a route declared like this:

const SearchSchema = z.object({
  page: z.coerce.number().int().min(1).max(9999).default(1),
  pageSize: z.coerce.number().int().min(1).max(100).default(20),
});

export const Route = createFileRoute("/_app/taxa/drafts")({
  validateSearch: (s) => SearchSchema.parse(s),


Is there something I'm not doing to enforce that the search params are optional on this route? I've tried also adding optional() to the zod schema, but it doesn't change anything, nor does (s?) as a validateSearch arg, or SearchSchema.parse(s ?? {}).
image.png
Was this page helpful?