Dev.to
7/22/2026

The original title is "React useCookie Hook: Cookies as Reactive State (2026)"
Original: React useCookie Hook: Cookies as Reactive State (2026)
Short summary
This article introduces useCookie from @reactuses/core, a React hook that treats browser cookies as reactive component state. It explains the pitfalls of hand-rolling cookie logic—stale reads, string parsing, SSR crashes—and shows how the hook solves them with a TypeScript-first API built on js-cookie. The hook supports functional updates, default values, and full cookie attribute handling (expires, path, SameSite, secure).
- •useCookie turns document.cookie into reactive React state with cross-component sync
- •Built on js-cookie for battle-tested attribute handling (expiry, path, SameSite)
- •Setting undefined deletes the cookie; defaults are written on mount for SSR visibility
Generated with AI, which can make mistakes.
Is this a good recommendation for you?


