Storage
With web storage, web applications can store data locally within the user's browser.
useLocalStorage
Usage
import React from 'react';
import useLocalStorage from '@/hooks/storage/useLocalStorage';
// Usage
function App() {
// Similar to useState but first arg is key to the value in local storage.
const [name, setName] = useLocalStorage("name", "Bob");
return (
<div>
<input
type="text"
placeholder="Enter your name"
value={name}
onChange={(e) => setName(e.target.value)}
/>
</div>
);
};useSessionStorage
Usage
Last updated