Add Teenybase to an Existing Project

You already have a frontend or app and want to add a teenybase backend.

Using a coding agent?

Create a backend folder

Run teeny create inside your project root. This creates a self-contained backend directory with its own package.json, teenybase.ts, worker entry point, and dev secrets.

bash
teeny create backend
cd backend
teeny deploy --local
teeny dev
bash
npx teeny create backend
cd backend
npx teeny deploy --local
npx teeny dev

Your backend API is at http://localhost:8787/api/v1.

Your project structure looks like this:

text
my-app/
  src/              # your frontend
  backend/          # teenybase backend (self-contained)
    teenybase.ts
    src/index.ts
    wrangler.jsonc
    .dev.vars
    package.json

Why a separate folder

  • The backend has its own dependencies (teenybase, hono, wrangler). Keeping them separate avoids conflicts with your frontend's package.json.
  • teeny deploy and teeny dev run from the backend directory. No config needed to tell them where to find things.
  • You can version, deploy, and test the backend independently.
  • If you use a monorepo tool (npm workspaces, turborepo, etc.), the backend folder is just another workspace.

Deploy

bash
cd backend
teeny register          # one-time
teeny deploy --remote
bash
cd backend
npx teeny register      # one-time
npx teeny deploy --remote

Next steps