routes.ts
Defines the route structure for your React Router application in Framework Mode. Located atapp/routes.ts.
Import
RouteConfig Type
Route Helpers
route()
Defines a route with a path and component.URL path pattern. Use
null or undefined for pathless layout routes.- Static:
"/about" - Dynamic:
"/users/:userId" - Splat:
"/files/*"
Path to route module file, relative to
app/ directory.Nested child routes.
Additional route options:
id?: string- Custom route identifiercaseSensitive?: boolean- Case-sensitive path matching
index()
Defines an index route (renders at parent’s path).Path to route module file.
Optional custom route ID.
layout()
Defines a layout route that wraps children without adding to the URL.Path to layout component file.
Routes to wrap with this layout.
Optional custom route ID.
prefix()
Adds a path prefix to multiple routes without a layout component.Path segment to prepend to all routes.
Routes to prefix.
File-System Routes
flatRoutes()
Generates routes from file-system structure using conventions.| File | Route |
|---|---|
routes/_index.tsx | / |
routes/about.tsx | /about |
routes/blog._index.tsx | /blog |
routes/blog.$slug.tsx | /blog/:slug |
routes/blog.$.tsx | /blog/* |
routes/users.$userId.tsx | /users/:userId |
routes/files.$.tsx | /files/* |
routes/_layout.tsx | Layout (no path) |
routes/dashboard.settings.tsx | /dashboard/settings |