useRouteLoaderData
Returns theloader 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 inroutes.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
Breadcrumbs
Conditional rendering
Comparison with useLoaderData
Type Safety
With TypeScript (Framework mode)
With TypeScript (Data mode)
Related
useLoaderData- Access current route’s loader datauseMatches- Get all active route matchesloader- Define route loaderOutlet- Render child routes