Docs
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Electric
PowerSync
Sentry
Railway
Prisma
Strapi
Unkey
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Electric
PowerSync
Sentry
Railway
Prisma
Strapi
Unkey
Integrations
Guides

Static Route Data

When creating routes, you can optionally specify a staticData property in the route's options. This object can literally contain anything you want as long as it's synchronously available when you create your route.

In addition to being able to access this data from the route itself, you can also access it from any match under the match.staticData property.

Example

Loading...

Enforcing Static Data

If you want to enforce that a route has static data, you can use declaration merging to add a type to the route's static option:

Loading...

Now, if you try to create a route without the customData property, you'll get a type error:

tsx
export const Route = createFileRoute('/posts')({
  staticData: {
    // Property 'customData' is missing in type '{ customData: number; }' but required in type 'StaticDataRouteOption'.ts(2741)
  },
})

Optional Static Data

If you want to make static data optional, simply add a ? to the property:

Loading...

As long as there are any required properties on the StaticDataRouteOption, you'll be required to pass in an object.

Common Patterns

Controlling Layout Visibility

Use staticData to control which routes show or hide layout elements:

Loading...
Loading...

Route Titles for Breadcrumbs

Loading...

When to Use staticData vs Context

staticDatacontext
Synchronous, defined at route creationCan be async (via beforeLoad)
Available before loading startsCan depend on params/search
Same for all instances of a routePassed down to child routes

Use staticData for static route metadata. Use context for dynamic data or auth state that varies per request.