DuskLocals
Request-scoped values that middleware, guards, loaders and server functions share.
Request-scoped values that middleware, guards, loaders and server functions share. Middleware sets
them on event.locals; they are read on the server only and never serialized into a page, a
payload or an API answer unless a loader or handler returns them on purpose.
Declare the keys once by merging into this interface (see defineLocals for a typed helper):
Import#
ts
import type { DuskLocals } from "@shadow-js/dusk/server";
Signature#
ts
interface DuskLocals {}
Examples#
ts
declare module "@shadow-js/dusk/server" {
interface DuskLocals {
user: { id: string; role: "reader" | "admin" } | undefined;
}
}