Skip to main content

useRouteLoaderData

Returns the loader data for a given route by route ID.
This hook only works in Data and Framework modes.

Signature

Parameters

string
required
The ID of the route to return loader data from. In Framework mode, route IDs are the path of the route file relative to the app folder without the extension.

Returns

SerializeFrom<T> | undefined
The data returned from the specified route’s loader function, or undefined if not found.

Usage

Basic usage

Access parent route data from a child route:

Framework mode route IDs

In Framework mode, route IDs are automatically generated from file paths:

Custom route IDs

You can specify custom route IDs in routes.ts:

Access user data globally

Common pattern for accessing authenticated user data:

Type-safe wrapper

Create a custom hook for type safety:

Access layout data

Share data between sibling routes

Common Patterns

Check if data exists

Conditional rendering

Comparison with useLoaderData

Type Safety

With TypeScript (Framework mode)

With TypeScript (Data mode)