useLoaderData()

Use useLoaderData() to read the loader result for the current matched route node.

const data = useLoaderData()

Returns

ComputedRef<T | null>

By default, T uses Horn's generated current-route loader data baseline.

  • useLoaderError() for the current node's loader error
  • useRouteLoaderData(routeId) for an explicit route id

useRouteLoaderData(routeId)

Use this when you want exact typing for a specific route:

const blogLayoutData = useRouteLoaderData('blog/layout')
const postData = useRouteLoaderData('blog/[slug]/page')

If you omit the routeId, Horn resolves the parent route id relative to the current matched node.

Typing behavior

useRouteLoaderData(routeId) is the most precise version because the route id is part of the generated type registry.