Manage Browser Cookies with React Hooks

twitter logo github logo ・1 min read

Browser Cookies

So this week, I created my first NPM package and my first custom React Hooks!!!

GitHub logo devhammed / use-cookie

Get, Set, Update and Delete Cookie using React Hooks.

@devhammed /use-cookie

Get, Set, Update and Delete Cookie using React Hooks.

NPM JavaScript Style Guide


npm install --save @devhammed


import React from 'react'
import ReactDOM from 'react-dom'
import useCookie from '@devhammed
const App = () => {
  const [username, setUsername, deleteUsername] = useCookie('username', 'User')
  return (
      <h1>Hello {username}!</h1&gt
      <p>Edit below input, Your name will be stored in a cookie. you can refresh this page to see how it persists.</p&gt
        onChange={(e) => setUsername(e.target.value)}
        onClick={() => deleteUsername()}
        Delete Cookie

ReactDOM.render(<App />, 

Want to you manage HTTP Cookies using React???
I created useCookie() React Hook, you can use it to Get, Set, Update and Delete Cookies in your functional components.

Demo: https://devhammed.github.io/use-cookie
NPM: https://www.npmjs.com/package/@devhammed/use-cookie

twitter logo DISCUSS
Classic DEV Post from Jun 27 '19

Jack Of All Trades or Master of One?

That age old question: how many pies should one have a thumb in?

Hammed Oyedele profile image
I am a self-taught Web Developer that develops intuitive Web applications that help businesses connect with their target audience, currently leading the Web Development team at Epower.ng.