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-appAliases: 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.tsGenerated 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 install2. Log In to the Compiler
quickback login3. Compile Your Definitions
quickback compile4. Run Migrations
npm run db:migrateThis 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:3000Note: Generate a strong random string for BETTER_AUTH_SECRET in production. You can use openssl rand -hex 32.
6. Start Development Server
npm run devYour 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 fileUnlike 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.sqlAvailable Scripts
| Script | Command | Description |
|---|---|---|
dev | bun run --hot src/index.ts | Start dev server with hot reload |
start | bun run src/index.ts | Start production server |
build | bun build src/index.ts --outdir ./dist --target bun | Build for production |
db:migrate | npx drizzle-kit migrate | Apply database migrations |
type-check | tsc --noEmit | Run 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 compileThe compiler regenerates the entire src/ directory for the new runtime target. Your feature definitions stay the same.
Next Steps
- Add a new feature — Define your own tables with security
- Configure access control — Set role-based permissions
- Add custom actions — Business logic beyond CRUD
- Cloudflare template — Deploy to production