Documentation Index
Fetch the complete documentation index at: https://veryfront.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Data fetching
Server data, static generation, and client-side fetching. Examples below use the default app router. Veryfront Code also supports the pages router throughveryfront.config.ts with router: "pages".
Prerequisites
- A project with at least one page (see Pages and routing).
- A data source you can call from server code, build-time scripts, or the browser (REST API, database, or in-memory data).
Server data
getServerData runs on every request. Use it when data depends on the request (auth, query params, cookies):
veryfront dev and open http://localhost:3000/dashboard?name=Grace. The page should render Welcome, Grace.
The 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:Verify it worked
- For
getServerData, hit the page withcurl http://localhost:3000/<path>and confirm the response contains the value you returned inprops. - For
getStaticData, runveryfront buildand inspect the generated HTML for the page. The HTML should contain the static value rather than a client-side fetch loop. - For client-side fetching, open the browser dev tools network tab. The request should fire after the page paints and the rendered output should match the response.
Next
- API routes: create the endpoints your pages fetch from
- Agents: load AI-generated data server-side
Related
veryfront(root):getServerData,getStaticData,redirect,notFound