Library API
    Preparing search index...

    Function setStorage

    • Sets or deletes a value in the active storage mechanism across any runtime environment. Automatically serializes objects for safe storage.

      Type Parameters

      • T

      Parameters

      • key: string

        The storage key to set

      • Optionalval: T

        The value to store (if undefined, the key is deleted)

      Returns void

      setStorage('user', { name: 'Alice' });
      setStorage('user', undefined); // deletes 'user'
      setStorage('coords', { lat: 10, lng: 20 }, { ttl: 86400000 }); // expires after 24h
    • Sets or deletes a value in the active storage mechanism across any runtime environment. Automatically serializes objects for safe storage.

      Type Parameters

      • T

      Parameters

      • key: string

        The storage key to set

      • val: T | undefined

        The value to store (if undefined, the key is deleted)

      • options: ServerStorageOptions

        Optional cache control options (server context only)

      Returns void

      setStorage('user', { name: 'Alice' });
      setStorage('user', undefined); // deletes 'user'
      setStorage('coords', { lat: 10, lng: 20 }, { ttl: 86400000 }); // expires after 24h