Hooks

useCookie

Publisher

cermuel

50 hooks published

More from this publisher

useCookie

Read, write, and remove cookies.

useCookie.tsx
import { useCookie } from "@cermuel/hooks/react";export function useCookieExample() {  const cookie = useCookie("theme", "system");  return <button type="button" onClick={() => cookie.set("dark")}>{cookie.value}</button>;}

Props

Param
Type
Default Value
name
string
initialValue
T
options?
CookieOptions<T>
{}

Returns

{ value: T; set: (next: T) => void; remove: () => void; }