---
source: https://iinventedlight.com/library/notes/react-usesyncexternalstore.md
title: "Subscribe to an external store with useSyncExternalStore"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (React docs); CC-BY-4.0 (React docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: React docs, useSyncExternalStore; React docs, You Might Not Need an Effect. CC-BY-4.0; CC-BY-4.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: React useSyncExternalStore"
tags: [react, usesyncexternalstore, store, subscribe]
client: Librarian
sources:
  - id: S1
    title: "useSyncExternalStore"
    publisher: React docs
    url: https://react.dev/reference/react/useSyncExternalStore
    accessed: 2026-11-19
    license: "CC-BY-4.0"
  - id: S2
    title: "You Might Not Need an Effect"
    publisher: React docs
    url: https://react.dev/learn/you-might-not-need-an-effect
    accessed: 2026-11-19
    license: "CC-BY-4.0"
---
# Subscribe to an external store with useSyncExternalStore
**Answer:** `useSyncExternalStore` is a React Hook that lets you subscribe to an external store. You pass a `subscribe` function, a `getSnapshot` function, and optionally `getServerSnapshot`. The Hook returns a snapshot of the store for this render.

## The Hook arguments

`subscribe` should subscribe to the store and return an unsubscribe function. `getSnapshot` should return the current store value. `getServerSnapshot` is used when rendering on the server. React will re-render when the subscription signals a change and the snapshot is different.

## Prefer this over an Effect

A `useOnlineStatus` example uses `useSyncExternalStore` with `online` and `offline` listeners. That is the built-in Hook for subscribing to an external store, instead of an Effect.

| useSyncExternalStore | arguments |
|---|---|
| subscribe | Subscribe and return an unsubscribe function |
| getSnapshot | Return the current store value |
| getServerSnapshot | Snapshot used when rendering on the server |
| useOnlineStatus | Example that uses online and offline listeners |

## See also

- [react-state](https://iinventedlight.com/library/notes/react-state/)
- [react-effects](https://iinventedlight.com/library/notes/react-effects/)
- [react-when-not-to-use-effect](https://iinventedlight.com/library/notes/react-when-not-to-use-effect/)

## Claims

- id: C1
  claim: useSyncExternalStore is a Hook that lets you subscribe to an external store.
  source: S1
  evidence: "subscribe to an external store"

- id: C2
  claim: It takes subscribe, getSnapshot, and an optional getServerSnapshot.
  source: S1
  evidence: "subscribe , getSnapshot , getServerSnapshot"

- id: C3
  claim: The learning guide uses it as a built-in Hook for subscribing to an external store, such as online status.
  source: S2
  evidence: "Subscribing to an external store with a built-in Hook"

## Sources

- [S1] useSyncExternalStore. React docs. https://react.dev/reference/react/useSyncExternalStore . License: CC-BY-4.0. Accessed 2026-11-19.

- [S2] You Might Not Need an Effect. React docs. https://react.dev/learn/you-might-not-need-an-effect . License: CC-BY-4.0. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: React docs, useSyncExternalStore; React docs, You Might Not Need an Effect. CC-BY-4.0; CC-BY-4.0. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
