A modern, full-stack monorepo template featuring Bun as the runtime, SvelteKit for the frontend, Hono for type-safe APIs, Prisma for database access, and Tailwind CSS for styling.
Install deps, start dev docker db, push schema to dev db, run web app dev server.
bun i
bun run docker:up
bun run db:push
bun run dev
āāā app/ # SvelteKit application
ā āāā src/
ā āāā routes/
ā āāā api/[...paths]/ # Hono API mount point
āāā pkg/
ā āāā api/ # Hono API package
ā ā āāā src/
ā ā āāā server.ts # Hono router
ā ā āāā client.ts # Type-safe API client
ā ā āāā routes/ # API route handlers
ā ā āāā adapter/ # SvelteKit adapter
ā āāā db/ # Prisma database package
ā āāā src/
ā āāā schema.prisma # Database schema
ā āāā prisma.ts # Prisma client
āāā docker-compose.yml # PostgreSQL for local dev
āāā package.json # Workspace root
# Clone the repository
git clone <repo-url>
cd bun-template
# Install dependencies
bun install
# Copy environment variables
cp .env.example .env
# Start PostgreSQL
bun docker:up
# Generate Prisma client & push schema
bun db:generate
bun db:push
# Start development server
bun dev
The app will be running at http://localhost:5173
| Command | Description |
|---|---|
bun dev |
Start development server |
bun build |
Build for production |
bun docker:up |
Start PostgreSQL container |
bun docker:down |
Stop & remove containers |
bun db:generate |
Generate Prisma client |
bun db:push |
Push schema to database |
bun db:migrate |
Run database migrations |
bun db:studio |
Open Prisma Studio |
The Hono API is mounted in SvelteKit at /api/*. Define routes in pkg/api/src/routes/:
// pkg/api/src/routes/users.ts
import { Hono } from 'hono';
import { zValidator } from '@hono/zod-validator';
import { z } from 'zod';
export const usersRouter = new Hono()
.get('/', async (c) => {
const users = await c.get('prisma').user.findMany();
return c.json(users);
})
.post('/', zValidator('json', z.object({
email: z.string().email(),
name: z.string()
})), async (c) => {
const data = c.req.valid('json');
const user = await c.get('prisma').user.create({ data });
return c.json(user);
});
Use the generated client for fully typed API calls:
// In SvelteKit components
import { api } from 'api/client';
const response = await api.users.$get();
const users = await response.json();
Define your schema in pkg/db/src/schema.prisma:
model User {
id String @id @default(cuid())
email String @unique
name String?
createdAt DateTime @default(now())
}
Then run:
bun db:generate # Generate client types
bun db:push # Sync schema to database
Tailwind v4 is pre-configured. Add styles in your Svelte components:
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Click me
</button>
Local development uses Docker Compose for PostgreSQL:
# docker-compose.yml
services:
db:
image: postgres:17
ports:
- 5432:5432
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: mysecretpassword
POSTGRES_DB: auth
# .env
DATABASE_URL="postgresql://root:mysecretpassword@localhost:5432/auth"
MIT