Each route in your project should have a corresponding routeInfo.ts file to define its schema using Zod. This schema controls the types for path parameters (params) and URL search parameters (search).
Defining Search Parameters
For routes like /search that use query strings, use the search key in the Route object:
export const Route = {
name: "Search",
params: z.object({}),
search: z.object({
q: z.string().optional(),
limit: z.coerce.number().optional()
})
};
Defining Path Parameters
For dynamic routes like /pokemon/[pokemonId], use the params key:
export const Route = {
name: "PokemonPokemonId",
params: z.object({
pokemonId: z.coerce.number()
})
};
Note: You can customize the exported name of the route object by changing the name key in routeInfo.ts. After changing the name, run pnpm dr:build to regenerate the files.