AntoineKM / useCookie

πŸͺ React Hook for Cookies based on js-cookie πŸͺ

Home Page:https://www.npmjs.com/package/@use-hook/use-cookie

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

useCookie - React Hook

React Hook for Cookies based on js-cookie

Instalation

npm install @use-hook/use-cookie --save

Usage

import { useCookie } from "@use-hook/use-cookie";

function App() {
  const [name, setName] = useCookie("name", "Stefan");

  return (
    <div>
      <input
        type="text"
        placeholder="Provide your name"
        value={name}
        onChange={e => setName(e.target.value, { expires: 1 })}
      />
    </div>
  );
}

Example

License

MIT

About

πŸͺ React Hook for Cookies based on js-cookie πŸͺ

https://www.npmjs.com/package/@use-hook/use-cookie


Languages

Language:JavaScript 100.0%