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.string | null | undefined
required
URL path pattern. Use
null or undefined for pathless layout routes.- Static:
"/about" - Dynamic:
"/users/:userId" - Splat:
"/files/*"
string
required
Path to route module file, relative to
app/ directory.RouteConfigEntry[]
Nested child routes.
object
Additional route options:
id?: string- Custom route identifiercaseSensitive?: boolean- Case-sensitive path matching
index()
Defines an index route (renders at parent’s path).string
required
Path to route module file.
{ id?: string }
Optional custom route ID.
layout()
Defines a layout route that wraps children without adding to the URL.string
required
Path to layout component file.
RouteConfigEntry[]
Routes to wrap with this layout.
{ id?: string }
Optional custom route ID.
prefix()
Adds a path prefix to multiple routes without a layout component.string
required
Path segment to prepend to all routes.
RouteConfigEntry[]
required
Routes to prefix.
File-System Routes
flatRoutes()
Generates routes from file-system structure using conventions.
Directory Structure Example: