Learn-skills.dev bun-monorepo-vite-elysia-spa
Scaffold or regenerate a Bun fullstack monorepo using official generators only: bun create elysia@latest for backend and bun create vite@latest --template react-ts for SPA frontend, then apply core backend wiring (Better Auth, Drizzle, MCP, OpenAPI, CORS, and security defaults). Use when creating or resetting a Bun workspace monorepo to latest generator versions.
install
source · Clone the upstream repo
git clone https://github.com/NeverSight/learn-skills.dev
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/NeverSight/learn-skills.dev "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/skills-md/ahmed-lotfy-dev/bun-monorepo-vite-elysia-spa/bun-monorepo-vite-elysia-spa" ~/.claude/skills/neversight-learn-skills-dev-bun-monorepo-vite-elysia-spa && rm -rf "$T"
manifest:
data/skills-md/ahmed-lotfy-dev/bun-monorepo-vite-elysia-spa/bun-monorepo-vite-elysia-spa/SKILL.mdsource content
Bun Workspace Vite Elysia SPA
Overview
Create a Bun workspace monorepo with latest generator output, not manual scaffolding. Use official generators first, then apply backend wiring and security defaults.
Required Workflow
- Confirm target path and whether existing
orapps/backend
should be replaced.apps/frontend - Run official generators only:
bun create elysia@latest apps/backendbun create vite@latest apps/frontend --template react-ts
- Install required backend dependencies and dev dependencies with Bun.
- Apply backend wiring using
(copied fromreferences/elysia-core-backend-reference.md
) for Better Auth, Drizzle, Postgres, MCP endpoint, OpenAPI docs, CORS allowlist, CSRF middleware, and security headers.elysia-core-backend - Keep frontend as SPA (Vite React TS) unless explicitly requested otherwise.
- Wire root Bun workspace scripts using Bun filters (
).bun run --filter "*" <script> - Provide run steps and env vars required for local development.
Hard Rules
- Do not hand-roll generated app baselines when Bun is available.
- Do not keep stale/legacy package versions from old manual scaffolds.
- Do not clobber existing apps without explicit confirmation.
- Prefer replacing app folders (
,apps/backend
) over patching old generated output when user asks for latest versions.apps/frontend
Backend Wiring Checklist
- Better Auth mounted and configured with Drizzle adapter.
- Drizzle schema and config present.
- Postgres connection via env
.DATABASE_URL - MCP plugin wired through
(not rawelysia-mcp
plugin use).McpServer - OpenAPI docs route enabled.
- CORS allowlist bound to frontend origin env.
- CSRF protection on non-auth cookie-based mutation routes.
- Security headers middleware enabled.
Frontend SPA Checklist
- React + TypeScript Vite template.
scripts present (vite
,dev
,build
) withpreview
binding host for LAN/WSL access.dev- Simple SPA entrypoint validated.
Run and Verify
bun install- Run all workspaces:
bun run --filter "*" dev - Run one workspace:
orbun run --filter frontend devbun run --filter backend dev - Frontend default port:
. Backend default port:3000
.8000 - For frontend direct run, use
.bun run dev --host 0.0.0.0 --port 3000 - For backend direct run, ensure
listens onsrc/index.ts
.8000
andbun run db:generate
in backend when DB is configured.bun run db:migrate
References
- Read
for exact commands, package lists, and file expectations.references/workflow.md - For any backend work, read
first (copied fromreferences/elysia-core-backend-reference.md
).elysia-core-backend - Upstream reference implementation:
.ahmed-lotfy-dev/elysia-core-backend