diff --git a/packages/search/src/use-search-history.ts b/packages/search/src/use-search-history.ts index 777c1fe..d572922 100644 --- a/packages/search/src/use-search-history.ts +++ b/packages/search/src/use-search-history.ts @@ -9,9 +9,9 @@ export function useSearchHistory({ limit, storageKey, }: UseSearchHistoryOptions) { - const [items, setItems] = React.useState(() => - readSearchHistory(storageKey, limit) - ) + // Keep the server render and the client's first render identical. Persisted + // history is restored by the effect after hydration. + const [items, setItems] = React.useState([]) React.useEffect(() => { const syncFromStorage = () => setItems(readSearchHistory(storageKey, limit))