SaaS Starter — Cursor + D1 + Railway
Full SaaS with auth, billing, and dashboard
Production-ready SaaS boilerplate with Clerk auth, Stripe subscriptions, and a Cloudflare D1 database. Designed for developers who want full control over their codebase.
What's Included
Authentication
Clerk auth with email, Google OAuth, and protected routes
Stripe Billing
Subscription checkout, webhooks, and customer portal
Dashboard
User dashboard with subscription status and usage stats
Transactional Email
Welcome email and password reset via Resend
Database
D1 schema with users, subscriptions, and sessions tables
Deploy Config
Railway deployment with one command
Setup Guide
Clone and install
Clone the starter repo and install dependencies.
$ git clone https://github.com/gptsters/saas-starter my-saas && cd my-saas && npm install
Set up Clerk auth
Create a free Clerk account at clerk.com. Copy your API keys from the Clerk dashboard.
Add to .env.local
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_SECRET_KEY=
💡 Free up to 10,000 monthly active users.
Create D1 database
Create a Cloudflare D1 database for your app data.
$ npx wrangler d1 create my-saas-db
Run migrations
Create the users, subscriptions, and sessions tables.
$ npx wrangler d1 migrations apply my-saas-db --remote
Configure Stripe
Create a Stripe account, add your products and prices, and copy your API keys.
Add to .env.local
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
💡 Use Stripe test mode until you're ready to accept real payments.
Set up Resend email
Create a Resend account and verify your sending domain.
Add to .env.local
RESEND_API_KEY=
💡 Free tier: 3,000 emails/month.
Deploy to Railway
Deploy your app with a single command.
$ npx railway login && npx railway up
Set Stripe webhook URL
In Stripe Dashboard → Webhooks, add your Railway URL: https://[your-app].up.railway.app/api/webhooks/stripe
💡 Railway gives you a URL instantly after your first deploy.
Cursor Prompt
Paste this into Cursor to generate the full codebase
Build a production SaaS with this stack: - Next.js 14 App Router, TypeScript strict mode - Cloudflare D1 with Drizzle ORM - Clerk for authentication - Stripe for subscriptions (webhook at /api/webhooks/stripe) - Resend for transactional email - Tailwind CSS + shadcn/ui Database tables: - users: id, clerk_id, email, name, created_at - subscriptions: id, user_id, stripe_customer_id, stripe_subscription_id, status, plan, current_period_end Build in order: 1. Auth middleware protecting /dashboard/* routes 2. User creation in D1 on Clerk webhook 3. Pricing page with monthly/annual toggle 4. Stripe webhook handler 5. Dashboard showing subscription status 6. Settings page with billing portal link Requirements: TypeScript strict, loading states, error boundaries, mobile responsive.
Tools You'll Need
Based on this starter's stack
Some links are affiliate links.
Common Issues
Related Starters
Frequently Asked Questions
~25 minutes. The setup guide walks you through every step with copy-paste commands. No guesswork.
Free to start. Railway's free tier includes 500 hours/month.
Yes. The starter kit gives you a working foundation. Use the included Cursor prompt to add features specific to your product.
Check our integration guides at /integrations and prompt library at /prompts for step-by-step instructions on adding any feature.