A production-ready, modern SaaS boilerplate built with the latest web technologies. This template provides everything you need to launch your next project quickly and efficiently.
โ Authentication System
โ User Management
โ Subscription & Billing
โ UI Components
โ Developer Experience
git clone https://github.com/yourusername/convex-sveltekit-boilerplate.git
cd convex-sveltekit-boilerplate
pnpm install
# or
npm install
Copy .env.example to .env.local:
cp .env.example .env.local
Fill in your environment variables:
# Convex
PUBLIC_CONVEX_URL=your_convex_url
PUBLIC_CONVEX_SITE_URL=your_convex_site_url
# Site
SITE_URL=http://localhost:5173
# Better Auth
BETTER_AUTH_SECRET=your_auth_secret # Generate with: openssl rand -base64 32
BETTER_AUTH_URL=http://localhost:5173
# OAuth (Optional)
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
# Resend
RESEND_API_KEY=your_resend_api_key
RESET_EMAIL_FROM="Your App <[email protected]>"
[email protected]
# Autumn (Stripe)
AUTUMN_API_KEY=your_autumn_api_key
PUBLIC_AUTUMN_PUBLISHABLE_KEY=your_autumn_publishable_key
# PostHog
PUBLIC_POSTHOG_API_KEY=your_posthog_api_key
PUBLIC_POSTHOG_HOST=https://app.posthog.com
# Anthropic (for AI SDK)
ANTHROPIC_API_KEY=your_anthropic_api_key
pnpm convex dev
This will:
In a new terminal:
pnpm dev
The app will be running at http://localhost:5173
convex-sveltekit-boilerplate/
โโโ convex/ # Convex backend
โ โโโ schema.ts # Database schema
โ โโโ auth.ts # Authentication config
โ โโโ users.ts # User queries/mutations
โ โโโ subscriptions.ts # Subscription queries/mutations
โโโ src/
โ โโโ lib/
โ โ โโโ components/ # Reusable components
โ โ โ โโโ ui/ # shadcn-svelte components
โ โ โ โโโ app-sidebar.svelte
โ โ โโโ server/ # Server-only code
โ โ โ โโโ auth.ts # Better Auth server config
โ โ โโโ utils/ # Utility functions
โ โ โโโ auth-client.ts # Auth client
โ โ โโโ convex-client.ts # Convex client
โ โ โโโ analytics.ts # PostHog config
โ โโโ routes/
โ โโโ (app)/ # Protected routes
โ โ โโโ dashboard/ # Dashboard pages
โ โ โโโ +layout.svelte # App layout with sidebar
โ โโโ (auth)/ # Auth routes
โ โ โโโ auth/
โ โ โโโ signin/
โ โ โโโ signup/
โ โโโ +page.svelte # Landing page
โโโ package.json
โโโ svelte.config.js
โโโ vite.config.ts
โโโ tailwind.config.js
For the best development experience, run both servers in parallel:
# Terminal 1 - Convex backend
pnpm convex dev
# Terminal 2 - SvelteKit frontend
pnpm dev
pnpm dev - Start development serverpnpm build - Build for productionpnpm preview - Preview production buildpnpm lint - Lint codepnpm format - Format code with Prettierpnpm check - Type-check with svelte-checkpnpm convex:dev - Start Convex dev serverpnpm convex:deploy - Deploy Convex backendpnpm convex deploy
Go to your Vercel project settings and add all the environment variables from .env.example.
Make sure to update:
SITE_URL to your production domainBETTER_AUTH_URL to your production domainPUBLIC_CONVEX_URL to your production Convex URLThis template uses shadcn-svelte for UI components. To add more components:
npx shadcn-svelte@latest add [component-name]
Edit src/lib/server/auth.ts to configure authentication providers and options.
Edit convex/schema.ts to add or modify tables. Convex will automatically sync your schema changes.
The template uses Tailwind CSS v4. Customize your theme in src/app.css.
This boilerplate uses neverthrow for type-safe error handling:
import { ok, err } from '$lib/utils/result';
function divide(a: number, b: number) {
if (b === 0) {
return err('Cannot divide by zero');
}
return ok(a / b);
}
const result = divide(10, 2);
result.match(
(value) => console.log('Success:', value),
(error) => console.error('Error:', error)
);
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
If you have any questions or need help, please:
Built with โค๏ธ using modern web technologies