DocsRendering and delivery
Static site generation
Render the real Rahti router at build time and publish its HTML and public assets without a separate template system.
Build static output
from the application root
cargo rahti build --static
cargo rahti build --static --out siteThe default output is dist/. Rahti performs normal application initialization, renders non-dynamic pages through the generated Axum router, resolves metadata, and copies the configured public directory.
| Route | Output |
|---|---|
| / | dist/index.html |
| /about | dist/about/index.html |
| /products/42 | dist/products/42/index.html |
| public/css/app.css | dist/css/app.css |
Declare dynamic paths
A dynamic page exports exact concrete URLs from an async static_paths() beside page(). The function may load application data after normal startup.
src/app/products/[slug]/page.rs
use axum::extract::Path;
use crate::rahti::{Html, html};
pub async fn static_paths() -> Vec<String> {
vec![
"/products/first".into(),
"/products/second".into(),
]
}
pub async fn page(Path(slug): Path<String>) -> Html {
html! { <h1>@{slug}</h1> }
}Each value starts with /, contains no query or fragment, and must match that page's route pattern. A dynamic page without the export is reported and skipped rather than guessed.
What static output can do
- Only successful HTML page responses are written.
- API routes, redirects, failures, extractor rejections, and non-HTML responses are skipped.
- Browser reactivity works, but RPCs, WebSockets, sessions, and request-time data still need a running server.
- Application middleware runs during export, so exportable pages must not require a live network peer.
