useLocalStorage

Keep a value in localStorage, in sync across components and tabs, safe for server rendering.

This is custom React hooks, you need to follow the Basic Rules when you use it.

General

The value survives a page reload.

APIs

useLocalStorage

const useLocalStorage = <T>(options: {
  key: string
  defaultValue: T
}) => [
  T,
  (value: T | ((current: T) => T)) => void,
  () => void,
]
Edit this page on GitHub