State Management · Senior · Question 38 of 75

How do you pass server-fetched data to SWR so the first client render has it?

Explanation

<SWRConfig value={{ fallback: { '/api/user': user } }}> makes useSWR('/api/user') return data immediately; SWR still revalidates according to its options.

Further reading

Problem with a question

State Management · Senior · question 38

Test yourself

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

Take this quiz