React Native Storage - v2.0.0
    Preparing search index...

    Interface ItemOptions<T>

    interface ItemOptions<T> {
        defaultValue?: T;
        schema?: Schema<T>;
        ttl?: number;
        version?: number;
        migrations?: Readonly<Record<number, Migration>>;
        legacy?: (raw: string) => unknown;
    }

    Type Parameters

    • T
    Index
    defaultValue?: T

    Returned when nothing is stored, the value expired, or stored data could not be read.

    schema?: Schema<T>

    Checks values on write and on read: a Standard Schema (Zod, Valibot, ArkType…) or a type guard.

    ttl?: number

    Default lifetime of a written value in milliseconds. set(value, { ttl }) overrides it.

    version?: number

    Schema version written with each value. Raise it when the shape changes. Default 1.

    migrations?: Readonly<Record<number, Migration>>

    migrations[n] upgrades a value from version n - 1 to n.

    legacy?: (raw: string) => unknown

    Reads text this library did not write, for example a value saved with plain AsyncStorage before you adopted it. Return the value in the current shape; it is validated and rewritten.