TanStackT
TanStack10mo ago
8 replies
sacred-emerald

Property 'isNewUser' does not exist on type '{}'** Route.useSearch

I'm using TanStack Router and have defined a search schema with isNewUser as an optional string parameter:

const dashboardSearchSchema = z.object({
  isNewUser: z.string().optional().default(""),
});

export const Route = createFileRoute(PATHS.DASHBOARD)({
  validateSearch: zodValidator(dashboardSearchSchema),
  component: DashboardPage,
});


However, when I try to access isNewUser from the search params:
const { isNewUser } = Route.useSearch();


TypeScript gives me the error: "Property 'isNewUser' does not exist on type '{}'"

It seems like the type inference isn't working correctly with the zod schema. How can I fix this type issue?
Was this page helpful?