Skip to content

Adding a page

Every page in Pulze is one component file plus one line in the route list. This guide adds a Reports page at /reports to the "Pages" group.

1. Copy the Blank page

Copy src/screens/pages/blank.tsx to src/screens/pages/reports.tsx, rename the function and change the header:

"use client"

import { PageHeader } from "@pulze/layout"
import { Button } from "@pulze/ui/components/button"

export default function ReportsPage() {
  return (
    <>
      <PageHeader
        title="Reports"
        description="Monthly numbers for the whole team."
        actions={<Button>Export</Button>}
      />
      {/* your blocks here */}
    </>
  )
}

Keep "use client" at the top. Pages use hooks (data, theme, motion).

2. Add it to the route list

In config/routes.ts:

{ path: "/reports", title: "Reports", section: "Pages", layout: "app", module: "pages/reports" },
Field Meaning
path The URL. Use :name for a parameter: /reports/:month
title Browser tab ("Reports · Pulze") and last breadcrumb
section First breadcrumb and ⌘K group
layout "app" (inside the shell), "auth" (sign-in style) or "bare" (full screen)
parent Optional. For detail pages, the list page shown in the breadcrumb
module The file from step 1, without src/screens/ and .tsx

3. Register it with your framework

Next.js: run

pnpm routes:sync

It creates app/(app)/reports/page.tsx:

import type { Metadata } from "next"
import Page from "@pulze/screens/pages/reports"

export const metadata: Metadata = { title: "Reports" }
export default Page

You can also create that file by hand. Remove its first comment line, and routes:sync will never overwrite it.

Vite: add a loader line to src/screens/loaders.ts:

"/reports": () => import("./pages/reports"),

The router reads routes.ts and loaders.ts, so there's nothing else to do. Each page downloads only when someone opens it.

4. Put it in the menu

In config/nav.ts, add it to a group:

{ label: "Reports", href: "/reports", icon: "chart" },

It now appears in the sidebar, the top-nav menu, the phone menu and ⌘K.

Pages with parameters

For /reports/:month:

  • Next.js: routes:sync creates app/(app)/reports/[month]/page.tsx.
  • Read the value in the page with the router-neutral hook:
import { useNav } from "@pulze/lib"

const { useParams } = useNav()
const { month } = useParams()

Always use useNav() (Link, usePathname, useParams, useSearchParams, useNavigate) instead of importing from next/navigation or react-router. That way the same page works in both versions.

Next.js only: a page that calls useSearchParams() must wrap that part in <Suspense>. Next.js requires this for pages it renders ahead of time.

Removing a page

  1. Delete its line in config/routes.ts and in config/nav.ts.
  2. Delete the page file in src/screens/.
  3. Next.js: delete its folder in app/. Vite: delete its line in src/screens/loaders.ts.