React useCookie Hook: Cookies as Reactive State (2026)
React useCookie Hook: Cookies as Reactive State (2026) A theme toggle stores the user's choice in a cookie so the server can render the right theme on the next request — no flash of the wrong mode. The component writes document.cookie = 'theme=dark', and then… nothing re-renders. document.cookie is not React state: writing it notifies nobody, reading it means parsing a semicolon-separated string, and there's no event to subscribe to when it changes. Every component that cares about that cookie i