# Templates

Quickback provides pre-configured templates to get you started quickly. Each template combines a runtime, database, and auth provider into a working project.

The fastest way to start is `quickback start` — an interactive picker that asks for a template + project name and scaffolds in the current directory if it's empty, otherwise creates a subfolder. Every template below can be reached either via `start`'s picker (free tier) or scriptably via `quickback create <template> <name>`.

```bash
# Interactive (recommended for first-time use)
mkdir my-app && cd my-app
npx @quickback-dev/cli start
```

## Available Templates

### Multi-tenant scaffolds (free)

Cloudflare Workers + D1 + Better Auth with the organization plugin and a `member` / `admin` / `owner` role hierarchy wired in.

| Template | Includes | Command |
|----------|----------|---------|
| `cloudflare` | Bare scaffold — auth + DB + Hono, no example feature | `quickback create cloudflare my-app` |
| `todos` | Working todos feature: schema, masking, two actions (`complete` / `uncomplete`), and a `dashboard` named view | `quickback create todos my-app` |

The **todos** template is the recommended first read — it exercises every security pillar (firewall, access, guards, masking) plus actions and views in ~80 lines you can scan in five minutes.

### Single-tenant starter (free)

| Template | Includes | Command |
|----------|----------|---------|
| `blog` | Single-tenant blog with PUBLIC reads, admin writes, `publish` / `unpublish` actions | `quickback create blog my-site` |

The **blog** template uses Better Auth's admin plugin (not the org plugin) and [single-tenant mode](/compiler/config/single-tenant) (`organizations: false`).

### Empty scaffold (free)

| Template | Includes | Command |
|----------|----------|---------|
| `empty` | `quickback.config.ts` only — no example features | `quickback create empty my-app` |

The empty template creates the project structure with `quickback.config.ts` only. Add your first feature by creating a file under `quickback/features/<name>/<name>.ts` exporting `defineTable(...)` — there is no separate `init` step.

### B2B SaaS (Pro)

| Template | Includes | Command |
|----------|----------|---------|
| `saas` | Multi-tenant + **R2 file storage** + **outbound webhooks** + split databases + realtime + named views | `quickback create saas my-app` |

## What Each Template Includes

The `cloudflare`, `todos`, `blog`, and `saas` templates all scaffold:

- **`quickback.config.ts`** — Pre-configured with the right providers
- **`quickback/features/`** — Feature definitions (empty for `cloudflare`; populated for `todos` / `blog` / `saas`)
- **Deployment scripts** — `npm run deploy` for Cloudflare via wrangler

The `empty` template includes only:

- **`quickback.config.ts`**
- **`package.json`** — dependencies ready to install

## Choosing a Template

### Cloudflare bare scaffold

Best when you already know the conventions and want empty walls. Multi-tenant orgs are wired in; you add your own feature files.

### Todos (recommended for newcomers)

Best for learning by reading. Full multi-tenant security pillars, two actions, a named view (`/api/v1/todos/views/dashboard`), and field masking on the `description` column — all in a single ~80-line file you can copy-edit into your own table.

### Blog (single-tenant CMS)

Best for personal sites, blogs, or any app with a single tenant. Uses [single-tenant mode](/compiler/config/single-tenant) — no organizations, roles come from `user.role` via Better Auth's admin plugin.

- Public JSON API for content
- Admin-only editing
- Pair with any frontend (Astro, Next.js, SvelteKit, etc.)

### Empty

Best when you know exactly what you want to build. Gets you the project structure and config without any opinionated features.

### SaaS (Pro)

Best for production B2B work. Adds R2 file uploads, outbound webhooks (with retry/dedupe), split auth/features/webhooks databases, realtime broadcast, and named views.

## Template Aliases

For convenience, templates have short aliases:

| Alias | Full id |
|-------|---------|
| `cloudflare` / `cf` | `betterauth-d1-cloudflare` |
| `todos` | `todos-cloudflare` |
| `blog` | `blog-cloudflare` |
| `saas` | `b2bsaas-cloudflare` |
| `empty` / `scaffold` | `empty-cloudflare` |

## After Scaffolding

`quickback start` runs scaffold + login + compile + install + drizzle in one flow. If you used the scriptable `quickback create` instead (or cancelled at the login prompt), finish setup with:

```bash
cd my-app
quickback compile   # prompts for login on first run; reuses session after
npm run dev
```

See the individual template guides for detailed setup:
- [Cloudflare Template](/compiler/getting-started/template-cloudflare)
- [Blog Template](/compiler/getting-started/template-blog)
- [Empty Scaffolding](/compiler/getting-started/template-empty)
- [Single-Tenant Mode](/compiler/config/single-tenant)
