Valcraven Docs
Building with Valcraven

Building with Valcraven

Practical, copy-paste recipes for extending the template — features, API routes, admin pages, migrations, realtime channels, chat tools, and API-key auth.

Building with Valcraven

This section is the how-to half of the docs: short, opinionated recipes for adding your own code on top of the template. Where Features explains what already ships, these pages show you how to extend it without fighting the conventions the template is built around.

Every recipe follows the same golden path — new authenticated features live inside /app, inside the existing app shell, and every route and query scopes its data to the signed-in user. Start with Add a feature; it ties the other recipes together end to end.

  • Add a feature — The golden path, start to finish: model the data, add the API route, and render the UI inside the /app shell (never a new public route, never a full-screen overlay).
  • Add an API route — The standard route handler: force-dynamic + nodejs, resolve the session, and return errors through errorResponse().
  • Add an admin page — How the /admin section is structured, how the RBAC gate works, and how to add a page plus its sidebar link.
  • Database migrations — Add a table to the schema, write a numbered migration, apply it locally, and ship it to Cloudflare D1.
  • Add a realtime channel — Publish server-side events and subscribe from the client with useRealtime, plus the single authorization seam you extend.
  • Add a chat tool — Give the AI agent a new tool it can call mid-conversation, following the built-in create_item / generate_image pattern.
  • Protect a route with API keys — Opt a route into sk_… API-key auth with authenticateRequest() and requireApiPermission().

Two conventions pages are worth reading alongside these: Code conventions for the house rules, and Gotchas for the sharp edges. Power users can go deeper in the admin-only dev wiki.

On this page