Skip to main content
Version: 0.24

Interface: Route

A URL path mapped to a Page.

Create one with the route constructor.

See Routing for path patterns (dynamic segments, optional segments, splats).

Extendsโ€‹

  • BaseSpecElement<"route">

Propertiesโ€‹

kindโ€‹

kind: "route"

The internal Wasp type of a SpecElement. Used by the compiler. You should not set this field directly, instead use the dedicated constructors.

Inherited fromโ€‹

BaseSpecElement.kind


lazy?โ€‹

optional lazy?: boolean

Lazy-load the page's component.

Set to false to include the page in the initial client bundle, which avoids the brief loading delay on first navigation at the cost of a larger initial download.

Defaultโ€‹

true

nameโ€‹

name: string

Unique route name.


pageโ€‹

page: Page

Page rendered when this route matches.


pathโ€‹

path: string

URL path. Supports React Router patterns like /tasks/:id, /photo/:id/edit?, and /files/*.


prerender?โ€‹

optional prerender?: boolean

If true, Wasp renders this page to static HTML at build time. Useful for SEO and AI crawlers.

Only works on fully static paths (no :paramName, *, or ? segments) and cannot be combined with Page.authRequired. See Prerendering.

Defaultโ€‹

false

Exampleโ€‹

import { app, page, route } from "@wasp.sh/spec"
import { SomePage } from "./src/SomePage" with { type: "ref" }

export default app({
// ...
spec: [
route("NameRoute", "/some-path", page(SomePage), {
prerender: true,
}),
],
})