Search...
clear( )
Removes all items from local, session, or memory storage.
Syntax
function clear(): void
clear Parameters
This function does not take any parameters.
Returns
This function does not return anything.
Return Type:
void
Related Content:
Was this helpful?
Remove all items from local storage
Copy Code
1import {local} from 'wix-storage-frontend';23// ...45local.clear();
Remove all items from session storage
Copy Code
1import {session} from 'wix-storage-frontend';23// ...45session.clear();
Remove all items from memory storage
Copy Code
1import {memory} from 'wix-storage-frontend';23// ...45memory.clear();
Manage data stored in the browser
This example shows how to manage data stored in the browser. Adjust the import statement to use different storage types. You can test out the code in our example template.
Copy Code
1import {local as storage} from 'wix-storage-frontend';2// Alternatively use:3// import {session as storage} from 'wix-storage-frontend';4// import {memory as storage} from 'wix-storage-frontend';56$w.onReady(async function () {7 $w('#setItemButton').onClick( () => {8 storage.setItem($w('#setKey').value, $w('#setValue').value);9 $w('#setKey').value = undefined;10 $w('#setValue').value = undefined;11 });1213 $w('#getItemButton').onClick( () => {14 $w('#getValue').value = storage.getItem($w('#getKey').value);15 $w('#getKey').value = undefined;16 });1718 $w('#removeItemButton').onClick( () => {19 storage.removeItem($w('#removeKey').value);20 $w('#removeKey').value = undefined;21 });2223 $w('#clearButton').onClick( () => {24 storage.clear();25 });26});27