Next.js · Middle · Question 13 of 75

How do you avoid a request waterfall if a component needs independent getUser() and getPosts()?

Explanation

Sequential awaits add up the waiting time. const [user, posts] = await Promise.all([getUser(), getPosts()]) runs them in parallel. Another option is to pass promises down and unwrap them with use() under separate Suspense boundaries so parts of the UI appear independently.

Further reading

Problem with a question

Next.js · Middle · question 13

Test yourself

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

Take this quiz