Skip to content

Latest commit

 

History

History
70 lines (50 loc) · 2.07 KB

README.md

File metadata and controls

70 lines (50 loc) · 2.07 KB

Welcome to @frankbolviken/localstorage-hook 👋

Version Documentation Maintenance License: MIT

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.

Prerequisites

  • node >=10

Install

npm install

Usage

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

Run tests

npm run test

Author

👤 Frank Bølviken

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2022 Frank Bølviken.
This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator