Static
hamur generate prerenders every route it reaches and builds, in this order, the preset of --preset; else the -static variant of the preset the config or the environment selects (vercel-static, netlify-static, cloudflare-static, cloudflare-pages-static, zeabur-static); else the selected preset when it prerenders (github-pages, gitlab-pages); else static. On Vercel, Netlify and Cloudflare Pages builds, hamur generate therefore writes the platform's own layout with its headers and redirects, and static is what it writes everywhere else. It prerenders every route it reaches by following links from /. A route with params that nothing links to is skipped, with a warning; list such paths in prerender.routes. A redirect answer is written as an HTML redirect page; any other non-2xx answer fails the build, unless prerender.failOnError is false. The message names the page that linked the failing path (/products/404: 404 (linked from /products/2)); leave such a path out with prerender.ignore, or set prerender.failOnError: false to get the same text as a warning. A page whose route middleware redirects is skipped with a warning instead of being written as a redirect page, because the build has no session and the redirect would apply to every visitor; give the route ssr: false to ship it as a client-rendered page, whose middleware runs in the browser. Links to files in public/ are not followed, prerender: false route rules and prerender.ignore leave paths out, and prerender.crawl: false turns link following off. Your own public/_redirects, _headers, 404.html and pages are kept; Hamur's lines are added after yours.
Reference
| Preset | static |
| Runs on | any static host |
event.runtime.name | static |
| Server target | bun |
| Lifetime, startup | process, load |
Output
.output/
hamur.json
public/ every prerendered page as <path>/index.html
200.html the single-page fallback
404.html
_headers, _redirects from your route rules, for hosts that read them
_hamur/ hashed client assets
Config keys
| Key | Default | What it does |
|---|---|---|
prerender.routes | none | paths to prerender besides the links the crawl follows |
prerender.crawl | unset: on for this preset | follow links from /; false turns it off |
prerender.errorPages | [404] | the <status>.html files written |
prerender.conflict | "warn" | what happens when two routes give one path |
prerender.onMissingId | "warn" | a crawled /page#x whose target element does not exist |
Detection
None. hamur generate picks it when no -static variant or prerendering preset applies; hamur build --preset static names it.
Deploy command
No hamur deploy command: it exits 1 for this preset. Upload .output/public/ to any static host. hamur generate builds this preset, or the -static variant of the preset the environment selects.
Limits
- Does not run: WebSockets and
server.syncedState,server.pubsub, streamed answers,server.metrics, image transforms at run time, privateapp/env.tsentries read at run time, Durable Object classes. hamur previewserves the files and404.html; it applies neither200.html,_headersnor_redirects.proxy,cors,swrandcacherules, server routes andserver.fallbackProxyare dropped with a warning (see the list above).tasks.runOnStartruns in the build only.
The levels are the features of the preset: hamur build warns or fails when the app uses a feature the preset does not run (see Preset features).
hamur generate
import { defineConfig } from "hamur"
export default defineConfig({
framework: "react",
prerender: { routes: ["/blog/hello", "/blog/world"], crawl: true, failOnError: true },
})
The output has 200.html, the single-page fallback, and 404.html. Point the host's fallback at them: unknown paths get 404.html, and a route that is not prerendered can use 200.html. hamur preview serves the files and 404.html for unknown paths only: it applies neither 200.html, _headers nor _redirects, which are for the host. The server is only used while building, so storage, sessions and server routes work during the build and nowhere after it. Server routes that a prerendered page links to are written as files.
The build also writes _headers and _redirects into .output/public/ from your headers, noindex and redirect route rules, for hosts that read them (Netlify and Cloudflare do; others ignore them). It writes no single-page fallback rule.
A static output serves files only, so after prerender the build warns once and lists what it drops:
[hamur] The static preset serves files only; these are dropped:
server route /api/hello (server/hello.ts)
server middleware server/index.ts (middleware[0])
server.openapi at /_hamur/openapi.json
route rule "/api/**" proxy
route rule "/blog/**" swr
The lines are handler routes whose path was not written as a file, the entries of the middleware list of server/index.ts, the GraphQL and OpenAPI paths when they are on, and route rules with proxy, cors, swr or cache. When nothing is dropped there is no warning.