More screenshots

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Backend Building: Graft tRPC, Drizzle and Hono Onto a Frontend

    1

    Add a real backend to an existing frontend: data model first, then tRPC procedures, Drizzle persistence, Hono server wiring, and auth last — verified before the UI ever connects.

    $5

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Backend Building: Graft tRPC, Drizzle and Hono Onto a Frontend

    Backend Building: Graft tRPC, Drizzle and Hono Onto a Frontend

    Example session with this skill installed

    My project-and-task tracker frontend works with mock data: a project list, a task board, tags. No backend, no accounts. Graft on a backend with persistence and accounts, and prove it works before the UI connects.

    • Read your context and instructions
    • Compiled the backend building

    BACKEND GRAFTED — model, schema, API, server, and auth verified; the UI can connect now.

    Step 1 — model on paper: User 1—* Project *—* Tag, Project 1—* Task. Task fields: title (required), status (todo/doing/done), due date (optional), project reference. IDs: UUID (project and task IDs appear in URLs). Timestamps on everything. Deletes: soft for projects (audit value), hard for tasks.

    Step 2 — schema: two files, schema/user.ts (users, sessions) and schema/project.ts (projects, tasks, tags, project–tag join). Migration generated, SQL read — foreign keys carry explicit onDelete: cascade for tasks under a project, set null for tags. Indexes on projectId and status. Applied to a fresh database; migrates cleanly.

    Step 3 — procedures: routers by domain — project.list, project.create, project.get; task.create, task.update, task.delete. Every input zod-validated at the boundary. task.create is protectedProcedure; the user id comes from context, never from input. Errors typed: NOT_FOUND for a missing project, FORBIDDEN for another user's project.

    Step 4 — Hono: tRPC mounted as middleware. Plain Hono routes: /health (liveness) and a stubbed /webhooks/stripe for future billing. CORS and logging in one place.

    Step 5 — auth: database sessions (revocability chosen over stateless JWT). Sign up → session → protected call → logout exercised end to end against the real database.

    Verification before the UI connects: (1) fresh-database migration clean. (2) Each procedure exercised directly — happy path works, empty task title rejected by zod, unauthorized access denied with 401. (3) Auth flow end to end. Only now does the frontend point at the API. The UI worked with mocks; it works identically with the real backend — and if one list renders empty, the bug is a contract drift between mock and API, which is the bug to fix.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    The frontend exists; the backend gets grafted on. The graft works when each layer is added in dependency order — data model → API → persistence → auth — and the UI stays untouched until the API is ready to serve it.

    Step 1 is the data model on paper first: entities and relationships as a short list, with IDs, timestamps, and soft-delete vs hard-delete decided before any code (arguing now is ten times cheaper than migrating later). Step 2 translates the model into a Drizzle schema — one file per bounded context, foreign keys with explicit onDelete behavior, indexes on every foreign key and filtered column, migrations append-only and their SQL read before applying. Step 3 builds the tRPC API contract: routers by domain, zod validation at the boundary, protectedProcedure vs publicProcedure as middleware (never an if-statement), one procedure per job, typed TRPCError codes. Step 4 wires the Hono server: tRPC for typed client-server calls, plain Hono routes for webhooks, uploads, and health checks, with auth context, logging, and CORS in one place. Step 5 adds auth last, after the API works with a stubbed user: session strategy decided up front, user id flowing through context (never taken as input — that's an impersonation bug waiting to happen).

    Verification runs before the UI connects: schema migrates cleanly on a fresh database, each procedure exercised directly (happy path, validation rejection, unauthorized denied), auth flow end to end. Only then does the frontend point at the API — and if the UI misbehaves, the bug is a contract drift from the mock, which is exactly the bug to fix.

    • It grafts onto an existing frontend; it is not a greenfield backend guide.
    • The code examples assume tRPC + Drizzle + Hono + TypeScript; other stacks need adaptation.
    • Auth is added last by design — if the app needs auth on day one before any API exists, the order still holds: build one working procedure with a stubbed user first.
    • A missing index on a filtered column works in dev and dies in production; the schema checklist exists for exactly that failure.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 3 days ago

    Permissions

    No special permissions declared or detected

    Listed3 days ago

    What's inside

    Frequently Asked Questions

    Because auth shapes the API around itself when it comes first. Build the API with a stubbed user, then wire real auth through context — the procedures end up shaped by the domain, not by the middleware.

    Because any client could then pass someone else's id. The user id flows from the session through context; input is for data, never for identity. Taking it as input is an impersonation bug waiting to happen.

    The contract drifted from the mock. The mock was the spec — compare the procedure's input/output shapes against what the UI expects, and fix the API side. That is exactly what the pre-connection verification is designed to catch.