@use-hook/use-cookie

React Hook for Cookies based on js-cookie

Usage no npm install needed!

<script type="module">
  import useHookUseCookie from 'https://cdn.skypack.dev/@use-hook/use-cookie';
</script>

README

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