/** * Per-route data loaders — getServerSideProps-style data fetching for JORVEL SSR. * * Each route can register a `defineLoader` that runs before render. The loader * receives a `LoaderContext` (URL, params, request, request-context) and may * return data, throw `redirect` / `json` / `notFound`, or set headers via the * provided helpers. Loaded data is exposed to components via{' '} * `useLoaderData()` when the same key is read on the client. * * Loaders aren't a router replacement — they're a single resolution slot per * SSR render, so the data is hydration-ready without a second client fetch. */ import type { EdgeRequest } from './types.js'; import type { RequestContext } from './request-context.js'; export interface LoaderContext

= Record> { request: EdgeRequest; url: URL; params: P; ctx: RequestContext | undefined; /** Set response headers from inside a loader (e.g. `Set-Cookie`). */ setHeader(name: string, value: string): void; } export type LoaderFn = Record> = (c: LoaderContext

) => Promise | T; export interface LoaderDescriptor { /** Stable key used to read the loaded data on the client. */ key: string; /** The loader function. */ load: LoaderFn; /** Optional `cache-control` for the response when this loader resolves. */ cacheControl?: string; } /** Type-narrowing helper that preserves the loader's return type. */ export declare function defineLoader = Record>(spec: { key: string; load: LoaderFn; cacheControl?: string; }): LoaderDescriptor; export declare function _clearLoaderSlot(): void; /** Read loaded data by key from inside a component. Returns `undefined` when missing. */ export declare function useLoaderData(key: string): T | undefined; /** Same as `useLoaderData` but throws when the slot is missing — for routes that require it. */ export declare function requireLoaderData(key: string): T; /** SSR boot helper to seed the slot from a serialized payload (hydration). */ export declare function setLoaderData(data: Record): void; export interface RunLoadersOptions { loaders: LoaderDescriptor[]; request: EdgeRequest; params?: Record; } export interface RunLoadersResult { data: Record; headers: Record; cacheControl?: string; } /** * Run a list of loaders concurrently and aggregate their data + headers. * Throws propagate (a loader can throw `redirect` / `json` / `notFound`). */ export declare function runLoaders(opts: RunLoadersOptions): Promise; //# sourceMappingURL=loaders.d.ts.map