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');