[]previous and next page

useLoaderData

The loader data of the route the component renders under, or of from.

The loader data of the route the component renders under, or of from. Reactive.

Import#

ts
import { useLoaderData } from "@shadow-js/router";

Signature#

ts
function useLoaderData<T = unknown, P extends RegisteredPath = RegisteredPath>(
  options: FromOptions<P> = {},
): Accessor<T | undefined>

Parameters#

Name Description
options from names the route.

Returns#

An accessor of the data (undefined before it loads, or when a loader failed).

Examples#

ts
const post = useLoaderData<Post>({ from: "/posts/:id" });