Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/netzo/deps/usehooks-ts.ts>useSessionStorage

Full-stack Deno framework for building business web apps like internal tools, dashboards, admin panels and automated workflows.
Go to Latest
function useSessionStorage
import { useSessionStorage } from "https://deno.land/x/netzo@0.4.78/deps/usehooks-ts.ts";

Custom hook for using session storage to persist state across page reloads.

Examples

const [count, setCount] = useSessionStorage('count', 0); // Access the count value and the setCount function to update it.

Type Parameters

T
  • The type of the state to be stored in session storage.

Parameters

key: string
  • The key under which the value will be stored in session storage.
initialValue: T | (() => T)
  • The initial value of the state or a function that returns the initial value.
optional
options: UseSessionStorageOptions<T>
  • Options for customizing the behavior of serialization and deserialization (optional).

Returns

A tuple containing the stored value and a function to set the value.