Use ReactNode with Async Server Components
Server Components can be
async and return a Promise<ReactNode>. React unwraps this promise using the nearest <Suspense> boundary. You can also pass a Promise<ReactNode> directly as children to implement streaming patterns.// Server Component returning a Promise
async function UserProfile({ userId }: { userId: string }) {
const user = await fetchUser(userId);
return <p>{user.name}</p>;
}
function Page() {
return (
<Suspense fallback={<p>Loading…</p>}>
<UserProfile userId="42" />
</Suspense>
);
}
// Passing a promise directly as children
function Page() {
const userPromise = fetchUser(); // Promise<ReactNode>
return <Suspense fallback={<Loading />}>{userPromise}</Suspense>;
}