To learn more about local, session, or memory storage, see wix-storage-frontend
.
Get hands-on experience with the Storage API on our Hello Storage example page.
To use the Frontend Storage API, import the needed storage type(s) from the
wix-storage-frontend
module:
import { local, session, memory } from "wix-storage-frontend";
// Or one of:
import { local } from "wix-storage-frontend";
import { session } from "wix-storage-frontend";
import { memory } from "wix-storage-frontend";
Removes all items from local, session, or memory storage.
function clear(): void;
import { local } from "wix-storage-frontend";
// ...
local.clear();
Gets an item from local, session, or memory storage.
If an item does not exist, getItem()
resolves to null.
function getItem(key: string): string;
The key of the item to get.
import { local } from "wix-storage-frontend";
// ...
let value = local.getItem("key"); // "value"
Removes an item from local, session, or memory storage.
function removeItem(key: string): void;
The key of the item to remove.
import { local } from "wix-storage-frontend";
// ...
local.removeItem("key");