Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages