Returns the loader data for a given route by route ID.
loader
Route IDs are created automatically. They are simply the path of the route file relative to the app folder without the extension.
app/root.tsx
"root"
app/routes/teams.tsx
"routes/teams"
app/whatever/teams.$id.tsx
"whatever/teams.$id"
The ID of the route to return loader data from
The data returned from the specified route's loader function, or undefined if not found
undefined
import { useRouteLoaderData } from "react-router";function SomeComponent() { const { user } = useRouteLoaderData("root");}// You can also specify your own route ID's manually in your routes.ts file:route("/", "containers/app.tsx", { id: "app" })useRouteLoaderData("app");@public Copy
import { useRouteLoaderData } from "react-router";function SomeComponent() { const { user } = useRouteLoaderData("root");}// You can also specify your own route ID's manually in your routes.ts file:route("/", "containers/app.tsx", { id: "app" })useRouteLoaderData("app");@public
framework
data
Returns the
loaderdata for a given route by route ID.Route IDs are created automatically. They are simply the path of the route file relative to the app folder without the extension.
app/root.tsx"root"app/routes/teams.tsx"routes/teams"app/whatever/teams.$id.tsx"whatever/teams.$id"