What is Teenybase?
Teenybase is a backend framework. You define your entire backend in a single TypeScript file (teenybase.ts) and deploy it with one command. Teenybase reads that file and generates the REST API, database migrations, auth endpoints, security rules, OpenAPI docs, and an admin panel.
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:
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 checkingThe 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/
How it works
teenybase.ts is the source of truth. When you run teeny deploy, the CLI diffs your config against the current database schema, generates SQL migrations, and applies them.
Locally:
teeny deploy --local # generate migrations + apply to local DB
teeny dev # start dev server at localhost:8787npx teeny deploy --local # generate migrations + apply to local DB
npx teeny dev # start dev server at localhost:8787To production:
teeny deploy --remote # generate migrations + deploy to productionnpx teeny deploy --remote # generate migrations + deploy to productionWhat'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 | R2, S3, or Backblaze |
| OpenAPI docs | Auto-generated 3.1.0 spec + Swagger UI |
| Admin panel | Browse tables, edit records, role-based access |
Deployment
Teenybase runs on SQLite. Three deployment options:
Teenybase Cloud. Managed hosting. Free tier included.
teeny register # one-time, free
teeny deploy --remote # deployednpx teeny register # one-time, free
npx teeny deploy --remote # deployedSelf-hosted on Cloudflare. Deploy to your own Cloudflare account with the same teeny deploy command.
Custom stack. Pluggable adapters for compute, database, and storage:
| Layer | Options |
|---|---|
| Compute | Cloudflare Workers, Node.js |
| Database | Cloudflare D1, Turso, local SQLite |
| Storage | Cloudflare R2, AWS S3, Backblaze B2 |
The default stack is Workers + D1 + R2. It deploys with one command and runs on Cloudflare's edge network.