Next.js 16 · Data and server code

Fetch data in a server component

Server components can be async, so fetch data directly.

export default async function Page() {
  const res = await fetch("https://api.example.com/posts");
  const posts = await res.json();
  return <ul>{posts.map((p: { id: number; title: string }) => <li key={p.id}>{p.title}</li>)}</ul>;
}

Official Next.js 16 documentation

More data and server code commands

All data and server code commands · Next.js 16 cheatsheet

Was this page helpful?