useStorage

Syncs state to local or session storage.


import { useLocalStorage } from 'primereact/hooks';
import { useSessionStorage } from 'primereact/hooks';
         

Refresh to page to view the persisted value.

0

const [count, setCount] = useLocalStorage(0, 'count');
         

Close the browser and visit this page again to view the persisted value.

0

const [count, setCount] = useSessionStorage(0, 'count');
         
Summer Sale 2025
SUMMER SALE2025
Use coupon code PRSM25 at checkout to get 50% OFF everything in PrimeStore and PrimeBlocks.
Learn More