useCookie
Reactive cookie reader and setter.
1.5 KB
•Updated on September 3, 2026
Installation
Bash
pnpm dlx shadcn@latest add @spaceui/hooks-browser-use-cookieUsage
Code
import { useCookie } from '@/hooks/use-cookie'
const [theme, setTheme, removeTheme] = useCookie('theme', 'dark')API Reference
Parameters / Props
| Parameter | Type | Default | Description |
|---|---|---|---|
name | string | required | Cookie name. |
initialValue | string | - | Initial default. |
Return Value
| Return Type | Description |
|---|---|
[string | null, (val: string) => void, () => void] | Tuple cookie state. |