···11+---
22+description:
33+globs: src/routes/**/*.tsx
44+alwaysApply: false
55+---
66+# TanStack Router: Do NOT Import createFileRoute
77+88+When working with TanStack Router route files in the [src/routes](mdc:src/routes) directory, **NEVER** import the `createFileRoute` function.
99+1010+## Why This Rule Exists
1111+1212+The `createFileRoute` function is automatically made available in each route file through TypeScript module declarations in [src/routeTree.gen.ts](mdc:src/routeTree.gen.ts). This file contains module augmentation that declares `createFileRoute` for each specific route:
1313+1414+```typescript
1515+declare module './routes/index' {
1616+ const createFileRoute: CreateFileRoute<...>
1717+}
1818+declare module './routes/basic' {
1919+ const createFileRoute: CreateFileRoute<...>
2020+}
2121+// ... and so on for each route
2222+```
2323+2424+## Correct Usage
2525+2626+✅ **DO THIS** - Use `createFileRoute` directly without importing:
2727+```tsx
2828+// src/routes/example.tsx
2929+export const Route = createFileRoute({
3030+ component: RouteComponent,
3131+});
3232+3333+function RouteComponent() {
3434+ // component logic
3535+}
3636+```
3737+3838+❌ **DON'T DO THIS** - Never import createFileRoute:
3939+```tsx
4040+// src/routes/example.tsx
4141+import { createFileRoute } from '@tanstack/react-router' // ❌ WRONG!
4242+4343+export const Route = createFileRoute({
4444+ component: RouteComponent,
4545+});
4646+```
4747+4848+## Key Points
4949+5050+- `createFileRoute` is globally available in route files through module declarations
5151+- Each route file gets its own typed version of `createFileRoute` with proper type safety
5252+- Importing it manually will cause TypeScript conflicts and is unnecessary
5353+- This pattern is automatically maintained by TanStack Router's code generation
5454+