A viewer preference in localStorage, read synchronously through useSyncExternalStore so the first paint already uses it, written in the setter rather than inside a React updater, shared by every instance using the same key (in-document listeners and the storage event), and kept in memory when storage throws. The consumer's parse owns validation.
pnpm dlx shadcn@latest add "https://pluginui.com/r/core-use-persistent-state.json"No files included in this item.