Skip to main content
zerotal

Documentation


Documentation / zerotal / view / definePage

Function: definePage()

definePage<P>(component): (ctx, params) => string | SafeHtml | Promise<string | SafeHtml>

Defined in: packages/core/src/view/index.ts:45

Declare a page handler: a function of (ctx, params) returning HTML (or a string / promise thereof), tagged via markViewComponent so the router treats it as a view component. Returns the same function with its type intact.

Type Parameters

P

P extends Record<string, unknown> = Record<string, unknown>

Parameters

component

(ctx, params) => string | SafeHtml | Promise<string | SafeHtml>

Returns

(ctx, params) => string | SafeHtml | Promise<string | SafeHtml>

Example

import { definePage } from '@zerotal/core/view';

export const Show = definePage<{ id: string }>((ctx, { id }) => (
  <article><h1>Post {id}</h1></article>
));