---
title: "What is teenybase?"
description: "teenybase turns one TypeScript file into a REST API, auth, access rules, migrations and an admin panel on Cloudflare Workers and D1, in your own account."
url: https://teenybase.com/docs/
last_updated: 2026-10-26
---

> Documentation index: https://teenybase.com/llms.txt lists every teenybase docs page with a link to its Markdown version. All docs in one file: https://teenybase.com/llms-full.txt

# What is Teenybase?

A teeny tiny Supabase for your own Cloudflare account.

Teenybase is a backend framework. You define your entire backend in a single TypeScript file (`teenybase.ts`) and deploy it with one command to Cloudflare Workers + D1 in your own Cloudflare account. Teenybase reads that file and generates the REST API, database migrations, auth endpoints, security rules, OpenAPI docs, and an admin panel.

Early (v0.1): APIs may change before 1.0.

## teenybase.ts

Your entire backend is defined in `teenybase.ts`. Tables, fields, auth, access rules, triggers. This example `teenybase.ts` sets up a `users` table with authentication and row-level security:

```typescript
import { DatabaseSettings, TableAuthExtensionData,
         TableRulesExtensionData } from 'teenybase'
import { baseFields, authFields,                        // ① Pre-built field sets
         createdTrigger, updatedTrigger } from 'teenybase/scaffolds/fields'

export default {
    appUrl: 'http://localhost:8787',                     // ② Used for OAuth redirects and email links
    jwtSecret: '$JWT_SECRET',                            // ③ Secret from .dev.vars ($-prefixed = env var)
    tables: [{
        name: 'users',                                   // ④ Table name → /api/v1/table/users/
        autoSetUid: true,                                // ⑤ Auto-generate unique ID on insert
        fields: [
            ...baseFields,                               // ⑥ id + created + updated
            ...authFields,                               // ⑦ username, email, password, name, avatar, role, etc.
        ],
        triggers: [createdTrigger, updatedTrigger],      // ⑧ Auto-manage created/updated timestamps
        extensions: [
            { name: 'auth',                              // ⑨ Enables sign-up, login, password reset, OAuth
              jwtSecret: '$JWT_SECRET_USERS',
              jwtTokenDuration: 3600,
              maxTokenRefresh: 5,
            } as TableAuthExtensionData,
            { name: 'rules',                             // ⑩ Row-level security
              listRule: 'auth.uid == id',                 //    Only see your own record
              viewRule: 'auth.uid == id',
              createRule: 'true',                         //    Needed for sign-up
              updateRule: 'auth.uid == id',
              deleteRule: 'auth.uid == id',
            } as TableRulesExtensionData,
        ],
    }],
} satisfies DatabaseSettings                             // ⑪ Full IDE autocomplete and type checking
```

The above produces a `users` table with:
- sign-up
- login
- JWT tokens
- password reset
- row-level security
- auto-migrations
- OpenAPI docs at `/api/v1/doc/ui`
- admin panel at `/api/v1/pocket/` (a fork of PocketBase's admin UI)

## How it works

`teenybase.ts` is the source of truth. When you run `deploy`, the CLI diffs your config against the current database schema, generates SQL migrations, and applies them.

Run the CLI with `npx teenybase <command>` (or `teeny <command>` after `npm i -g teenybase`). Don't use `npx teeny`: that is an unrelated npm package.

Locally:

```bash
npx teenybase deploy --local --yes   # generate migrations + apply to the local DB
npx teenybase dev                    # start dev server at localhost:8787
```

To your Cloudflare account:

```bash
npx wrangler login                   # one-time
npx teenybase deploy --remote --yes  # generate migrations + deploy
```

## What's included

| Feature | Description |
|---|---|
| REST API | CRUD endpoints for every table |
| Auth | Email/password, JWT, OAuth (Google, GitHub, Discord, LinkedIn) |
| Row-level security | Rules like `auth.uid == owner_id`, compiled to SQL WHERE clauses |
| Auto-migrations | No migration files to write |
| Actions | Server-side logic with typed params, callable via API |
| Full-text search | SQLite FTS5 |
| File uploads | Cloudflare R2 |
| OpenAPI docs | Auto-generated 3.1.0 spec + Swagger UI |
| Admin panel | Browse tables, edit records, role-based access (fork of PocketBase's admin UI) |

## Where it runs

Teenybase runs serverless on Cloudflare Workers, with Cloudflare D1 (SQLite) as the database and R2 for files, all in your own Cloudflare account. There is no teenybase server in between: you own the Worker, the database and the data.

## Next steps

- [Quickstart](https://teenybase.com/docs/getting-started/quickstart)
- [Config Reference](https://teenybase.com/docs/reference/config-reference)
- [Cost Breakdown](https://teenybase.com/docs/reference/cost-breakdown)
- [Why Teenybase](./why-teenybase)
