Function: route()
route(
name,path,page,config?):Route
Creates a Route definition.
Maps a URL path to a Page. Paths support React Router patterns
such as dynamic segments (/tasks/:id), optional segments
(/photo/:id/edit?), and splats (/files/*).
Use config.prerender to render the route to static HTML at build time
(see Prerendering) and
config.lazy to opt out of lazy-loading the page's bundle.
Parameters
name
string
Unique name for the route.
path
string
URL path the route matches.
page
The result of page().
config?
Optional route settings (lazy, prerender).
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
prerender?
boolean
If true, Wasp renders this page to static HTML at build time. Useful
for SEO and AI crawlers.
Only works on static paths and cannot be combined with Page.authRequired. See Prerendering.
Default
false
Returns
Example
import { page, route } from '@wasp.sh/spec'
import MainPage from './src/MainPage' with { type: 'ref' }
route('MainRoute', '/', page(MainPage))