Skip to main content

Route API

Routes define the URL structure, data loading, and rendering for your application.

createRoute

Creates a non-root Route instance for code-based routing.

Parameters

RouteOptions
required
Route configuration options.

Returns

Route
A Route instance to be attached to the route tree.

Route Methods

Route instances expose several type-safe methods for use in components:

route.useMatch()

Get the current route match data.

route.useParams()

Access the route’s path parameters.

route.useSearch()

Access the route’s search parameters.

route.useLoaderData()

Access the route’s loader data.

route.useLoaderDeps()

Access the route’s loader dependencies.

route.useNavigate()

Get a navigate function pre-bound to this route.

route.useRouteContext()

Access the route’s context.
A pre-bound Link component for this route.

createRouteMask

Create a route mask for displaying a route at a different path.

Parameters

object
required

Returns

RouteMask
A route mask object to pass to the router’s routeMasks option.

Component Types

RouteComponent

A standard route component type.

ErrorRouteComponent

An error boundary component type with error props.

NotFoundRouteComponent

A not-found component type with routing props.