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 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
npx teenybase create backend --yes
cd backend
npx teenybase deploy --local --yes
npx teenybase 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.
  • npx teenybase deploy and npx teenybase 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 ​

Deploy the backend to your own Cloudflare account:

bash
cd backend
npx wrangler login          # one-time
npx teenybase deploy --remote --yes

Next steps ​