Docs/Creating a Page
CREATING A PAGE

Creating a Page

To create a page, create a page.ts (or .tsx if you prefer) file within the <project-root>/pages directory.

You can also put your page in a subdirectory, which will change the destination folder where it's available. For example, /pages/blog/page.ts(x) will be viewable at http://localhost:3000/blog. The convention of using the file-system for routing is called fs-routing.

Writing Content to the Page

You've made a page, but now it's time to add real content to it.

Elegance matches popular convention, and requires you to export a default function which returns a VirtualNode. If you're not familiar with what a default export is, brush up on it here

A simple page might look something like this:

ts
const counter = state(0); export default function CounterPage() { return div( button({ onClick: () => counter.value++; }, `Counter: ${counter.value}` ) ); }