File: usestorage.md | Updated: 11/15/2025
Introducing PrimeReact v11 Alpha 🥁Learn More
SearchK
10.9.7
HOOK
API
Syncs state to local or session storage.
Import#
import { useLocalStorage } from 'primereact/hooks';
import { useSessionStorage } from 'primereact/hooks';
Copy
Local#
Refresh to page to view the persisted value.
0
const [count, setCount] = useLocalStorage(0, 'count');
Copy
Session#
Close the browser and visit this page again to view the persisted value.
0
const [count, setCount] = useSessionStorage(0, 'count');
Copy
Import
Local
Session
PrimeReact 10.9.7 by PrimeTek