Documentation
    Preparing search index...

    Interface IStorage

    Async key-value store used by the SDK to persist protocol state (session keys, last connected wallet info, restoration markers).

    In the browser the SDK uses window.localStorage by default. In Node.js, React Native or any other environment without a localStorage global the dApp MUST pass a custom implementation on TonConnectOptions.storage.

    import type { IStorage } from '@tonconnect/sdk';

    const memoryStorage = {
    state: new Map<string, string>(),
    setItem(k, v) { this.state.set(k, v); return Promise.resolve(); },
    getItem(k) { return Promise.resolve(this.state.get(k) ?? null); },
    removeItem(k) { this.state.delete(k); return Promise.resolve(); },
    } satisfies IStorage & { state: Map<string, string> };
    interface IStorage {
        getItem(key: string): Promise<null | string>;
        removeItem(key: string): Promise<void>;
        setItem(key: string, value: string): Promise<void>;
    }
    Index

    Methods

    • Read the value previously stored under key, or null if absent.

      Parameters

      Returns Promise<null | string>

    • Delete the value stored under key. A no-op if the key does not exist.

      Parameters

      • key: string

        — string identifier to remove.

      Returns Promise<void>

    • Persist value under key. Overwrites any existing value.

      Parameters

      • key: string

        — string identifier, scoped per dApp.

      • value: string

        — value to save.

      Returns Promise<void>