/** * Client-side glue that runs a file route's `load` on navigation and exposes * the result reactively — the browser counterpart to the SSR router bridge. * * The loader runs whenever the active route changes (mirroring how the server * runs it before render), with stale-response guarding so a slow loader for a * route you have already navigated away from cannot clobber fresher data. * * @module bquery/router */ import { type ReadonlySignal } from '../../reactive/index'; import type { Route, RouteDefinition, Router } from '../types'; import type { Action, Load } from './types'; /** Read the `load` attached to a route by {@link createFileRoutes}, if any. */ export declare const getRouteLoad: (route: Route | RouteDefinition | null) => Load | undefined; /** Read the `action` attached to a route by {@link createFileRoutes}, if any. */ export declare const getRouteAction: (route: Route | RouteDefinition | null) => Action | undefined; /** Options for {@link createRouteData}. */ export interface RouteDataOptions { /** Ambient context forwarded to the loader (rarely needed on the client). */ ctx?: unknown; /** Request forwarded to the loader (e.g. when replaying a server request). */ request?: Request; /** Abort signal forwarded to the loader. */ signal?: AbortSignal; /** Override how the loader's `url` is derived from a route. */ urlFor?: (route: Route) => URL; } /** A reactive handle over the active route's loaded data. */ export interface RouteData { /** The most recently loaded data, or `undefined` before the first load. */ data: ReadonlySignal; /** `true` while a loader is in flight. */ pending: ReadonlySignal; /** The error from the most recent failed load, or `null`. */ error: ReadonlySignal; /** Re-run the loader for the current route. */ refresh: () => Promise; /** Stop reacting to route changes. */ destroy: () => void; } /** * Subscribe to a router and run the matched route's `load` on every * navigation, exposing `data` / `pending` / `error` signals. The returned * handle is also registered as the ambient handle read by {@link useRouteData}. * * @example * ```ts * const router = createRouter({ routes }); * const { data, pending } = createRouteData(router); * effect(() => render(data.value)); * ``` */ export declare const createRouteData: (router: Router, options?: RouteDataOptions) => RouteData; /** * Read the ambient {@link RouteData} handle created by the most recent * {@link createRouteData} call. Returns an inert handle if none exists yet, so * components can call it unconditionally. * * @example * ```ts * const { data, pending } = useRouteData<{ user: User }>(); * ``` */ export declare const useRouteData: () => RouteData; //# sourceMappingURL=data.d.ts.map