Zod v4 parse path params always string?

1 week ago 15
ARTICLE AD BOX

I'm using @tanstack/zod-adapter for parsing path params:

export const Route = createFileRoute( "/route/$one/$two/$three", )({ params: zodValidator( z.object({ one: z.number(), two: z.string(), three: z.string(), }), )}, component: RouteComponent, });

However, when routing using a <Link /> component:

<Link to="/route/$one/$two/$three" params={{ one: 1234, two: "value", three: "otherValue", }} > {/* ... */} </Link>

The expected result here would be that it was a number inside the route, instead Zod throws an error since the param is a string?

Read Entire Article