Building Your Application

Build a feature in the Cloudflare kit: create a page, load data, submit a form, authenticate the user, and test the result.

Start here after Installation. This guide explains how to build application features with the conventions this kit actually uses: Void Pages, React, self-managed Better Auth, and Drizzle on Postgres.

What Do You Want to Build?

I want to…Start with
Add a page and put it in the sidebarPages, Routes and Layouts
Fetch data for a pageFetching Data
Save a form or run a mutationMutations and Forms
Get the signed-in user or check permissionsUsers, Sessions and Permissions
Add a JSON endpoint or call it from ReactAPI Routes
Add a table, write a query, or apply migrationsDatabase and Services
Add an application emailCustom Emails
Test a feature and debug failuresTesting and Debugging

For daily commands, see Command Reference. For ongoing work, see Kit Updates and Building with Coding Agents.

How a Feature Fits Together

A page normally needs two files: its React component and a companion .server.ts file. The server file loads data and accepts mutations. Put database operations and business rules in named service functions, then call them from those handlers.

Page reads pass through middleware, an authorized loader and a service. Form writes validate and authorize before mutation, then reload or redirect.Click to expand

Loaders and actions run on the server. React page components render on the server initially and hydrate in the browser. A component's import type of its loader props is erased from the browser bundle; importing a server function into a component is a different operation and must be avoided.

Follow One Small Feature

The first three guides build an account summary at /account-summary:

  1. Generate the page and add its labels and navigation entry.
  2. Read the current user's profile with a scoped database query.
  3. Add a validated display-name form using the kit's existing account service.

The page and query are new examples you add to your app. The mutation reuses the real updateOwnName function, so the kit's name validation, hooks, and rate limits continue to apply. You do not need to invent a projects table to follow these examples.

Where to Put Things

CodeLocation
Signed-in pagesapps/web/pages/(app)/
Public pagesapps/web/pages/, outside (app)/ and auth/
Page loaders and actionsBeside the page, with the same name and .server.ts
API endpointsapps/web/routes/api/
App services and validatorsapps/web/lib/*.service.ts and *.schema.ts
Your database tablesapps/web/db/schema.ts
App labelsapps/web/messages/en/app.json, or your own namespace
Sidebar itemsapps/web/config/navigation.config.tsx
Reusable packagespackages/<name>/src/, with separate client and server entries

For specialized work, continue to background jobs, file storage, billing, translations, and configuration.


Next: Create a Page →