wix-storage

wix-storage

The wix-storage module contains functionality for the persistent storage of key/value data in the user's browser.

There are two types of storage:

  • Local — Data in local storage never expires, even if the user closes your page. When the user reopens the page later, the data can still be retrieved.

  • Session — Data in session storage is available while the user's web session is active. The session ends when the user closes the browser tab or window. When the session ends, all the data in session storage is lost. Reloading or restoring the page does not affect session storage data.

To use the Storage API, import the needed storage type(s) from the wix-storage module:

ICAgaW1wb3J0IHtsb2NhbCwgc2Vzc2lvbn0gZnJvbSAnd2l4LXN0b3JhZ2UnOwoKICAgLy8gT3Igb25lIG9mOgoKICAgaW1wb3J0IHtsb2NhbH0gZnJvbSAnd2l4LXN0b3JhZ2UnOwogICBpbXBvcnQge3Nlc3Npb259IGZyb20gJ3dpeC1zdG9yYWdlJzs=
   import {local, session} from 'wix-storage';

   // Or one of:

   import {local} from 'wix-storage';
   import {session} from 'wix-storage';

The APIs in wix-storage can only be used in front-end code.

To work with the data in session and local storage use the functions described here.

Some older browsers may not fully support wix-storage. See Browser compatibility for more information.

Contents

Storage Used for storing local or session key/value data in the user's browser.
local Used for local storage of data.
session Used for session storage of data.
local

local

Used for local storage of data.

Syntax

import {local} from 'wix-storage';

Description

Use the methods in Storage to manage local data.

Type

Storage

session

session

Used for session storage of data.

Syntax

import {session} from 'wix-storage';

Description

Use the methods in Storage to manage session data.

Type

Storage