main
Branches
main (2.15.1)dev
Versions
2.15.11.19.3v0.21.0
React Router v7 has been released. View the docs
useRouteLoaderData

useRouteLoaderData

Returns the loader data for a given route by ID.

import { useRouteLoaderData } from "@remix-run/react";

function SomeComponent() {
  const { user } = useRouteLoaderData("root");
}

Remix creates the route IDs automatically. They are simply the path of the route file relative to the app folder without the extension.

Route Filename Route ID
app/root.tsx "root"
app/routes/teams.tsx "routes/teams"
app/routes/teams.$id.tsx "routes/teams.$id"
Docs and examples licensed under MIT