Skip to content
renkudocs
GuidesRouting

Routing

Routes are explicit data in renku.config.ts. The Worker matches a URL, loads that page and its layout chain, and renders a new document. This site's guide navigation uses ordinary links.

On this page

An index route matches its parent address. Static paths outrank named parameters, and page/layout paths point to default-exported TSRX components. Only the matched module chain is imported on the server; CSS remains one application stylesheet.

renku.config.ts
import { bindings, defineConfig } from "renku";

export default defineConfig({
  worker: {
    name: "my-app",
    compatibilityDate: "2026-10-06",
    env: { ASSETS: bindings.assets() },
  },
  routes: [{
    layout: "./src/document.tsrx",
    children: [
      { index: true, page: "./src/home.tsrx" },
      { path: "notes/:id", page: "./src/note.tsrx" },
    ],
  }],
});

PageProps<"id"> declares the required parameter. The build checks that the route supplies it. Values arrive as strings decoded once; validate domain IDs and permissions before using them for data access.

src/note.tsrx
import type { PageProps } from "renku";

export default function Note({ params }: PageProps<"id">) @{
  <article>
    <h1>Note: {params.id}</h1>
    <a href="/">Back home</a>
  </article>
}

Links, reload, browser history and deep links all use document navigation. There is no retained client router. Unmatched routes return 404, malformed paths return 400, and matched pages support GET and HEAD.

The /guides/:topic route on this site demonstrates a parameter; /guides/client-rendering is a more specific static route.

Add prerender: ["/", "/about"] to defineConfig to serve selected public pages as Cloudflare assets without running the application Worker. Choose synchronous pages independent of cookies, query strings, request origin and per-request data.

Build preparation rejects async components and server capability imports and has no bindings or network. Client roots can still fetch live session state, as on antgrade. Both slash forms serve the same document; query strings are ignored.

Public URLs revalidate with no-cache; hashed HTML is immutable. Development keeps routes live. Paths must be unique, use letters, digits, hyphens, underscores and /, have no trailing slash except /, and fit within 900 characters. Up to 48 paths are supported.

This does not enable offline caching: configure pwa.prepare separately.

Cloudflare serves generated and public assets before page dispatch. The build rejects public files that collide with configured page patterns. /_renku is reserved for generated assets; do not shadow it with routes or redirect rules.

You can configure typed page routes, handle native navigation and select public prerendered routes.

Continue to layouts

← All guides · Explore the docs source (access required) →