Function: useRunStorageScope()
useRunStorageScope<
T>(fn):Promise<T>
Defined in: src/infrastructure/storage/storage.service.ts:316
Runs fn with request-isolated in-memory storage (SSR).
Use this around a request handler so useSetStorage / useGetStorage
share state within the request but not across requests.
In browser environments, this simply calls fn() directly (no ALS needed).
Type Parameters
T
T
Return type of fn.
Parameters
fn
() => T | Promise<T>
The function to run within the storage scope.
Returns
Promise<T>
The return value of fn.
Example
import { useRunStorageScope, useSetStorage, useGetStorage } from "katanakit-js";
export default defineEventHandler((event) => {
return useRunStorageScope(() => {
useSetStorage("req-id", event.context.id);
return useGetStorage("req-id");
});
});