React · Senior · Question 68 of 75

How can a Server Component start a fetch but let a Client Component wait for it?

// server
const commentsPromise = getComments(postId);
return <Comments commentsPromise={commentsPromise} />;
// client
const comments = use(commentsPromise);

Explanation

Promises are serializable props. The page shell renders immediately, and the comments stream in when the promise resolves.

Further reading

Problem with a question

React · Senior · question 68

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