Server data
getServerData runs on every request. Use it when data depends on the request (auth, query params, cookies):
DataContext provides:
| Property | Type | Description |
|---|---|---|
request | Request | The incoming HTTP request |
params | Record<string, string> | Route parameters (e.g. { slug: "hello" }) |
query | URLSearchParams | Query string parameters |
Static data
getStaticData runs at build time. Use it for content that doesn’t change per request:
getStaticData with getStaticPaths to tell the framework which pages to generate.
Redirects and 404s
Returnredirect() or notFound() from any data function:
redirect() accepts an optional second argument for permanent redirects:
Client-side fetching
For data that loads after the page renders, fetch in a client component:Next
- API Routes: create the endpoints your pages fetch from
- Agents: load AI-generated data server-side
Related
veryfront(root):getServerData,getStaticData,redirect,notFound