A modern, production-ready starter template with high-performance tech stack.
/api/v1pnpm install
Copy .env.example to .env and fill in your values:
cp .env.example .env
Required variables:
DATABASE_URL - Supabase connection string (use pooling mode)BETTER_AUTH_SECRET - Generate with: openssl rand -base64 32BETTER_AUTH_URL - Your app URL (http://localhost:5173 for dev)Push the schema to Supabase:
pnpm db:push
Or generate and run migrations:
pnpm db:generate
pnpm db:migrate
Other Commands:
npx svelte-kit sync
npx drizzle-kit generate
openssl rand -base64 32
npx @better-auth/cli generate
pnpm dev
Create a default admin user:
pnpm db:seed
Default credentials: [email protected] / Password123!
Open http://localhost:5173 in your browser.
src/
āāā lib/
ā āāā server/
ā ā āāā api/ # ElysiaJS API routes
ā ā ā āāā routes/ # Route modules
ā ā ā āāā index.ts # Main API app
ā ā āāā db/
ā ā ā āāā schema/ # Drizzle schemas
ā ā ā āāā index.ts # DB connection
ā ā āāā auth.ts # Better-Auth server config
ā āāā auth-client.ts # Better-Auth client
āāā routes/
ā āāā api/v1/[...slugs]/ # ElysiaJS catch-all route
ā āāā (auth)/ # Auth pages (login, register)
ā āāā (protected)/ # Protected pages (requires auth)
ā āāā +page.svelte # Home page
āāā app.css # TailwindCSS entry
āāā app.d.ts # TypeScript types
āāā hooks.server.ts # Server hooks
| Script | Description |
|---|---|
pnpm dev |
Start development server |
pnpm build |
Build for production |
pnpm preview |
Preview production build |
pnpm check |
Type check with svelte-check |
pnpm db:generate |
Generate Drizzle migrations |
pnpm db:migrate |
Run migrations |
pnpm db:push |
Push schema to database |
pnpm db:studio |
Open Drizzle Studio |
pnpm db:seed |
Seed database |
pnpm db:verify |
Verify database |
The ElysiaJS API is mounted at /api/v1. Example endpoints:
GET /api/v1 - API infoGET /api/v1/example - Example endpointGET /api/v1/example/:id - Get by IDPOST /api/v1/example - Create itemAdd new routes in src/lib/server/api/routes/.
Better-Auth handles authentication via:
src/lib/server/auth.ts - Configuration and APIsrc/lib/auth-client.ts - React hooks for auth statesrc/hooks.server.ts - Handles auth requestsRoutes under (protected)/ require authentication. The layout server checks session and redirects to login if not authenticated.
Drizzle ORM with PostgreSQL via Supabase:
src/lib/server/db/schema/src/lib/server/db/index.tsdrizzle.config.ts[YOUR-PASSWORD] with your database password