0.1.0 • Published 2 years ago

@frankbolviken/localstorage-hook v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

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