#36415·storybook

[Bug]: Tanstack Router: Typesafety Gaps, query params is not typed, path params is not required

Author: timofei-iatsenkoCreated Sep 24, 2026Updated Sep 28, 2026
Labelsbugreacttypescriptsev:S3

Describe the bug

I identified few Typesafety Gaps in native Tanstack Router integration:

Say we have a route with path param and search (query params):

typescript
import { createFileRoute } from '@tanstack/react-router';
import { zodValidator } from '@tanstack/zod-adapter';
import { z } from 'zod';

const searchSchema = z.object({
  filter: z.string(),
});

export const Route = createFileRoute('/category/$id')({
  component: RouteComponent,
  validateSearch: zodValidator(searchSchema),
});

function RouteComponent() {
  const params = Route.useParams();

  return (
    <>
      <div>Hello "/category/$id"!</div>
      <div>ID: {params.id}</div>
    </>
  );
}

Case 1: Typesript does not complain about omit path/query params:

typescript
const meta = {
  title: 'Example/Story With Params',
  parameters: {
    layout: 'fullscreen',
    tanstack: {
      router: {
        route: Route,  // <-- no TS errors, required `filter` query param is not passed, required `$id` path param is not passed
      },
    },
  },
} satisfies Meta<typeof Route>;

Case 2: query (search) params is completely not typed.

typescript
const meta = {
  title: 'Example/Story With Params',
  parameters: {
    layout: 'fullscreen',
    tanstack: {
      router: {
        route: Route,
        query: {
           bla: "bla" // <-- should complain because "bla" is not defined in schema; should complain about missing "filter" param
        }
      },
    },
  },
} satisfies Meta<typeof Route>;

The strongly typed query params is one of the selling points of the Tanstack Router, it's a bit disappointing that they are not typed in the Storybook integration.

I see from the storybook sources that query property has a code to be strongly typed, but it doesn't work in my project and in the example.

Maybe some additional configuration needed and here is a gap in the documentation? BTW FileRoutesByPath type is correctly registered in storybook files and correctly resolved to whatever is generated in the routeTree.gen

Image

Reproduction link

https://stackblitz.com/edit/github-dg6vzy1n-mc1aw6fc?file=src%2Fstories%2FCategory.stories.tsx

Reproduction steps

I'm not sure this issue could be reproduced in the stackblitz. So it's better to download the code and run this locally (to check both tsc and language server).

I created a src/stories/Category.stories.tsx which is rendering a src/routes/category.$id.tsx

System

bash
Storybook Environment Info:
│

│  System:
│  OS: macOS 26.5.2
│  CPU: (16) arm64 Apple M3 Max
│  Shell: 5.9 - /bin/zsh
│  Binaries:
│  Node: 24.21.0 -
│  /Users/timofei.Iatsenko/Projects/multibrand-fe-spa/node_modules/.bin/node
│  Yarn: 4.18.0 - /Users/timofei.Iatsenko/.nvm/versions/node/v24.13.1/bin/yarn
│  npm: 11.8.0 - /Users/timofei.Iatsenko/.nvm/versions/node/v24.13.1/bin/npm
│  pnpm: 12.3.4 - /Users/timofei.Iatsenko/.nvm/versions/node/v24.13.1/bin/pnpm
│  <----- active
│  Browsers:
│  Chrome: 153.0.8010.53
│  Safari: 26.5.2
│  npmPackages:
│  @storybook/addon-docs: 10.6.0 => 10.6.0
│  @storybook/addon-links: 10.6.0 => 10.6.0
│  @storybook/addon-onboarding: 10.6.0 => 10.6.0
│  @storybook/addon-themes: 10.6.0 => 10.6.0
│  @storybook/builder-vite: 10.6.0 => 10.6.0
│  @storybook/tanstack-react: 10.6.0 => 10.6.0
│  eslint-plugin-storybook: 10.6.0 => 10.6.0
│  msw-storybook-addon: ^3.0.3 => 3.0.3
│  storybook: 10.6.0 => 10.6.0

Additional context

No response