/** * Per-request context for SSR. The edge adapter populates the context before * rendering; React components read from it via `getRequestContext()`. Each * request gets its own object so concurrent renders never interleave. * * Implementation note: we deliberately stay edge-runtime-safe and avoid * `node:async_hooks`. Instead a single "current request" slot is set on the * adapter's renderer call — renders are synchronous from the slot's * perspective, so per-request isolation holds as long as `runWithRequestContext` * brackets the render call. Concurrent edge renders are typically isolated * across separate `fetch()` invocations in distinct microtask chains; we still * support an opt-in AsyncLocalStorage via `setRequestContextStore` for Node * deployments that need it. */ export interface RequestContext { url: string; method: string; headers: Record; cookies: Record; /** Free-form per-request bag. Populate from middleware (user, locale, etc.). */ locals: Record; } interface Store { get(): RequestContext | undefined; set(ctx: RequestContext): void; /** Optionally run `fn` with `ctx` scoped to the duration of the call. */ run(ctx: RequestContext, fn: () => T): T; } /** Swap the underlying store (e.g. an AsyncLocalStorage-backed one in Node). */ export declare function setRequestContextStore(store: Store): void; /** Read the current request context, or `undefined` outside a render. */ export declare function getRequestContext(): RequestContext | undefined; /** Same as `getRequestContext()` but throws when missing. */ export declare function requireRequestContext(): RequestContext; /** Run `fn` with `ctx` set as the current request context. */ export declare function runWithRequestContext(ctx: RequestContext, fn: () => T): T; export declare function parseCookies(header: string | undefined): Record; export declare function buildRequestContext(req: { url: string; method?: string; headers?: Record; }): RequestContext; export {}; //# sourceMappingURL=request-context.d.ts.map