Skip to content
forma.
v3.0
☰
Browse documentation
Start here
Build interfaces
Native rendering
Tooling
Security and operations
Architecture
Application guides
API reference

Docs/API reference

FORMA 3.0

@getforma/core/storage

Typed localStorage, sessionStorage and IndexedDB wrappers.

View source ↗Markdown ↓Source 2006423
On this page

Generated from the published 3.0.0 TypeScript declarations. Signatures, overloads and JSDoc are taken from the package; private class members are omitted. Declaration links point to version-pinned package files.

These wrappers store data in the browser. They do not supply server persistence. StorageOptions can validate a deserialized value; a generic type alone does not validate stored data.

Read the usage guide or all entry points.

6 exports · published 3.0.0 declarations

ts
import { createIndexedDB } from '@getforma/core/storage';

Values and functions

createIndexedDB#

Function export · Declaration, line 75

ts
declare function createIndexedDB<T>(dbName: string, storeName?: string): IDBStore<T>;

Create a simplified IndexedDB store.

ts
const store = createIndexedDB<User>('myApp', 'users');
await store.set('u1', { name: 'Alice' });
const user = await store.get('u1'); // { name: 'Alice' }

Related declarations: IDBStore

createLocalStorage#

Function export · Declaration, line 31

ts
declare function createLocalStorage<T>(key: string, options?: StorageOptions<T>): TypedStorage<T>;

Create a typed localStorage wrapper for the given key.

ts
const store = createLocalStorage<{ name: string }>('user');
store.set({ name: 'Alice' });
store.get(); // { name: 'Alice' }
store.remove();

Related declarations: StorageOptions, TypedStorage

createSessionStorage#

Function export · Declaration, line 50

ts
declare function createSessionStorage<T>(key: string, options?: StorageOptions<T>): TypedStorage<T>;

Create a typed sessionStorage wrapper for the given key.

ts
const store = createSessionStorage<{ token: string }>('auth');
store.set({ token: 'abc123' });
store.get(); // { token: 'abc123' }
store.remove();

Related declarations: StorageOptions, TypedStorage

Exported types

IDBStore#

Interface export · Declaration, line 58

ts
interface IDBStore<T> {
    get(key: string): Promise<T | undefined>;
    set(key: string, value: T): Promise<void>;
    delete(key: string): Promise<void>;
    getAll(): Promise<T[]>;
    keys(): Promise<string[]>;
    clear(): Promise<void>;
}

Forma Storage - IndexedDB

Simplified IndexedDB wrapper with lazy connection and promise-based API. Zero dependencies — native browser APIs only.

StorageOptions#

Interface export · Declaration, line 7

ts
interface StorageOptions<T> {
    serialize?: (v: T) => string;
    deserialize?: (s: string) => T;
    validate?: (v: unknown) => v is T;
}

Member notes

validate

Optional validator — return true if the deserialized value is valid.

TypedStorage#

Interface export · Declaration, line 1

ts
interface TypedStorage<T> {
    get(): T | null;
    set(value: T): void;
    remove(): void;
    key: string;
}

Other entry points

@getforma/core · @getforma/core/runtime · @getforma/core/runtime-hardened · @getforma/core/runtime-csp · @getforma/core/tc39 · @getforma/core/http · JSX namespace

Find your next answer.

Search Forma 3.0 documentation, guides and examples.