React · Senior · Question 63 of 75

Why does useSyncExternalStore accept a getServerSnapshot argument?

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.

Further reading

Problem with a question

React · Senior · question 63

Test yourself

Take the React · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz