Static Routes
Static routes are the simplest StatikAPI routes.
A file path maps directly to a route path:
src-api/
index.js -> /
about.js -> /about
team/info.js -> /team/info
In the regular CLI output model, those become:
api-out/index.json
api-out/about/index.json
api-out/team/info/index.json
Example: plain value
// src-api/index.js
export default {
hello: 'world',
generatedAt: '2026-05-09T12:00:00.000Z',
};
This is the most direct route form:
- no
paths() - no
params - no route-level special handling required
Example: function form
You can also export a function:
// src-api/about.js
export default async function data() {
return {
name: 'StatikAPI',
kind: 'static-route-example',
};
}
That is useful when the value is still static-route-shaped but computed at build time.
When to use a static route
Use a static route when:
- the path is known ahead of time
- you do not need URL params
- the route is a singleton endpoint such as:
//about/site-metadata
If you need multiple concrete pages from one file, use:
Serialization reminder
Static routes still must return JSON-serializable data.
That means:
- strings are fine
- numbers are fine
- plain objects/arrays are fine
Dateobjects are not fine
If you want a timestamp, serialize it yourself:
export default {
generatedAt: new Date().toISOString(),
};