createSessionStorage
Create a storage instance backed by globalThis.sessionStorage. The underlying storage is resolved lazily from globalThis when the instance is used, so it can be imported before a browser-like global exists. Values persist for the duration of the page session when available.
Usage
js
import { createSessionStorage } from '@studiometa/js-toolkit/utils';
const storage = createSessionStorage({ prefix: 'session:' });
storage.set('token', 'abc123');
storage.set('expires', 3600);
storage.get('token'); // 'abc123'Parameters
options(StorageOptions): Optional configuration.options.prefix(string): Key prefix for namespacing.options.serializer(StorageSerializer): Custom serializer. Defaults to JSON.
Return value
StorageInstance<T>: See createStorage for the full API.