Skip to main content
Version: 0.24

Function: page()

page(component, config?): Page

Creates a Page definition.

A page is a React component rendered by a route.

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

Parameters

component

Reference<AnyFunction>

The React component to render.

Use reference imports when passing values from your app into the Wasp spec. If a direct import is not practical, use ref as a fallback.

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 })