React hook which syncs the state to the browsers localstorage. All references to localstorage handled in a way which makes this hook work in nextjs serverside rendered applications.
🏠 Homepage
- node >=10
npm install
import useLocalStorage from '@frankbolviken/localstorage-hook';
const App = () => {
const [user, setUser] = useLocalStorage < string > ('username', 'John doe');
return (
<div>
The username is {user}
<button onClick={() => setUser('Batman')}>Change</button>
</div>
);
};
npm run test
👤 Frank Bølviken
- Github: @frankbolviken
- LinkedIn: @frankbolviken
Give a ⭐️ if this project helped you!
Copyright © 2022 Frank Bølviken.
This project is MIT licensed.
This README was generated with ❤️ by readme-md-generator