Quickback Docs

Bun Template

Step-by-step guide to creating a Quickback project with Bun and local SQLite.

The Bun template creates a backend running on Bun with a local SQLite database and Better Auth. No cloud account needed — ideal for local development and prototyping.

Create the Project

quickback create bun my-app
cd my-app

Aliases: quickback create local my-app

This scaffolds a project with:

my-app/
├── quickback/
│   ├── quickback.config.ts       # Compiler configuration
│   └── features/
│       └── todos/
│           ├── todos.ts          # Schema + security (defineTable)
│           └── actions.ts        # Custom actions
├── src/                          # Compiled output (generated)
├── drizzle/                      # Migrations (generated)
├── data/                         # SQLite database files
├── package.json
├── tsconfig.json
└── drizzle.config.ts

Generated Configuration

quickback.config.ts

import { defineConfig } from "@quickback/define";

export default defineConfig({
  name: "my-app",
  template: "hono",
  features: ["organizations"],
  providers: {
    runtime: { name: "bun", config: {} },
    database: {
      name: "better-sqlite3",
      config: { path: "./data/app.db" },
    },
    auth: { name: "better-auth", config: {} },
  },
});

The Bun template includes the same todos feature as the Cloudflare template with all four security pillars configured.

Setup Steps

1. Install Dependencies

bun install

2. Log In to the Compiler

quickback login

3. Compile Your Definitions

quickback compile

4. Run Migrations

npm run db:migrate

This creates the SQLite database in data/app.db and applies all migrations.

5. Create Environment File

Create a .env file in your project root:

# Runtime
NODE_ENV=development
PORT=3000

# Auth
BETTER_AUTH_SECRET=your-secret-key-change-in-production
BETTER_AUTH_URL=http://localhost:3000

Note: Generate a strong random string for BETTER_AUTH_SECRET in production. You can use openssl rand -hex 32.

6. Start Development Server

npm run dev

Your API is running at http://localhost:3000 with hot reload.

Database

The Bun template uses better-sqlite3 with a local SQLite file stored in data/app.db. The generated database module automatically:

  • Creates the data/ directory if it doesn't exist
  • Enables WAL mode for better concurrent performance
  • Enables foreign key constraints
data/
└── app.db          # SQLite database file

Unlike the Cloudflare template, Bun uses a single database for both auth and feature tables. Migrations are in a single directory:

drizzle/
├── meta/
│   ├── _journal.json
│   └── 0000_snapshot.json
└── 0000_initial.sql

Available Scripts

ScriptCommandDescription
devbun run --hot src/index.tsStart dev server with hot reload
startbun run src/index.tsStart production server
buildbun build src/index.ts --outdir ./dist --target bunBuild for production
db:migratenpx drizzle-kit migrateApply database migrations
type-checktsc --noEmitRun TypeScript type checking

Switching to Cloudflare

When you're ready to deploy to production, you can switch to the Cloudflare template by updating your quickback.config.ts:

import { defineConfig } from "@quickback/define";

export default defineConfig({
  name: "my-app",
  template: "hono",
  features: ["organizations"],
  providers: {
    runtime: { name: "cloudflare", config: {} },
    database: {
      name: "cloudflare-d1",
      config: { binding: "DB" },
    },
    auth: { name: "better-auth", config: {} },
  },
});

Then recompile:

quickback compile

The compiler regenerates the entire src/ directory for the new runtime target. Your feature definitions stay the same.

Next Steps

On this page