Skip to main content
Version: Next

Function: page()

page(component, config?): Page

Creates a Page definition.

A page is a React component rendered by a route. Pass the component as the first argument, either via a reference import (recommended) or an ExtImport object.

See Routing and the Auth overview for protecting pages with authRequired.

Parameters

component

Reference<AnyFunction>

The React component to render.

config?

Optional page settings such as authRequired.

authRequired?

boolean

If true, only authenticated users can access this page. Unauthenticated visitors are redirected to Auth.onAuthFailedRedirectTo.

Cannot be combined with Route.prerender.

Default

false

Returns

Page

Example

import { page } from '@wasp.sh/spec'
import MainPage from './src/MainPage' with { type: 'ref' }

page(MainPage, { authRequired: true })