uselocalstorage-react-hook

1.0.5 • Public • Published

NPM

Uselocalstorage-React-Hook

This is an amazing package that will help you add local storage variables easily in your react app.

🛠️ Installation

  1. Install using npm
npm i uselocalstorage-react-hook
  1. Add to your project
import useLocalStorage from "uselocalstorage-react-hook";
  1. Start using uselocalstorage-react-hook
const [name, setName] = useLocalStorage("name", "John Doe");

💻 Example Code

import React from "react";
import "./styles.css";
import useLocalStorage from "uselocalstorage-react-hook";

const App = () => {
  const [name, setName] = useLocalStorage("name", "John Doe");

  return (
    <div>
      <input
        type="text"
        value={name}
        onChange={(e) => setName(e.target.value)}
      />
      <h1>{name}</h1>
      <p>Refresh this page, the name remains the same. 🤟</p>
    </div>
  );
};

export default App;

🦄 Live Demo

🙌 Thanks

Thanks to everyone who contributed to the development of this project.

If you enjoyed, go follow me on Twitter 💖

🛡️ License

MIT Licensed. Copyright (c) Savio Martin.

Package Sidebar

Install

npm i uselocalstorage-react-hook

Weekly Downloads

13

Version

1.0.5

License

MIT

Unpacked Size

280 kB

Total Files

3

Last publish

Collaborators

  • saviomartin