React · Senior · Question 67 of 75

How do you avoid a waterfall when a Server Component needs two independent requests?

const [user, posts] = await Promise.all([getUser(id), getPosts(id)]);

Explanation

Sequential awaits double the latency. Separate Suspense boundaries additionally let the faster part stream in first.

Further reading

Problem with a question

React · Senior · question 67

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