Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

Use the browser's Storage API instead of the server with fresh

Notifications You must be signed in to change notification settings

ionutrogojan/browserStorage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Deno Fresh browserStorage

The fresh localStorage object is a server side component that does not work with Deno Deploy. browserStorage uses instead the browser's Web Storage API to update the keys and values.

Import

import { lengthStorage, keyStorage, getStorage, setStorage, removeStorage, clearStorage } from "https://deno.land/x/[email protected]/mod.ts";

Examples

    setStorage("deno", "fresh");
    // adds or updates { key: "deno" , value: "fresh" } to browser localStorage

    keyStorage(0);
    // returns the key name at index 0 : "deno"

    getStorage("deno");
    // returns the value of the key : "fresh"

    lengthStorage();
    // returns the browser localStorage length : 1, or 0 if no key is found

    removeStorage("deno");
    // removes { key: "deno" , value: "fresh" } from browser localStorage

    clearStorage();
    // clear all the browser localStorage keys