React · Senior · Question 63 of 75
Why does useSyncExternalStore accept a getServerSnapshot argument?
- ✓Correct answer: To provide the value used during SSR and hydration, so server and client render the same initial HTML
- 2To fetch data from the server
- 3To subscribe to server-sent events
Explanation
Browser-only stores (e.g. localStorage, media queries) have no value on the server. A consistent server snapshot avoids hydration mismatches; the real value is applied right after.