Skip to content

Latest commit

 

History

History
230 lines (178 loc) · 10.1 KB

README.md

File metadata and controls

230 lines (178 loc) · 10.1 KB

SaaS Monorepo Template

License Stars CI Next.js 16 Expo SDK 55 TypeScript Buy me a coffee Tweet

Production-ready SaaS starter — web + mobile, batteries included.
Next.js 16 · Expo SDK 55 · Stripe · RevenueCat · Better-Auth · Drizzle ORM · Turborepo

Quick start · What's included · Features · Deploy · Contributing · Sponsor

Deploy with Vercel

SaaS Monorepo Template — web dashboard + mobile app


Use this template to ship a full SaaS product — web dashboard + iOS/Android app — in days instead of months. Every integration is wired up and working out of the box.

What's included

Layer Web Mobile
Framework Next.js 16 (App Router) Expo Router
UI shadcn/ui — Radix + Tailwind v4 NativewindUI — NativeWind
Auth Better-Auth (RBAC via admin plugin) Better-Auth HTTP + AsyncStorage
Payments Stripe — Checkout, Portal, Webhooks RevenueCat — IAP (iOS + Android)
Database Drizzle ORM + PostgreSQL via Web API
Email Resend + React Email templates via Web API
Background Jobs Inngest — event-driven + cron —
Rate Limiting Upstash Redis —
Analytics PostHog PostHog
Error Tracking Sentry Sentry
Tracing OpenTelemetry (OTLP) —
Feature Flags PostHog (server + client) —
Canary Rollouts Vercel Edge Config —
Testing Vitest + happy-dom —
CI/CD GitHub Actions → Vercel GitHub Actions → EAS Build

How does it compare?

No other open-source SaaS starter ships a complete web + mobile monorepo with dual payment processing.

This template create-t3-turbo Open SaaS (Wasp) Saasfly ShipFast Supastarter Makerkit
Price Free Free Free Free $199+ $299+ $299
Mobile app (Expo) Yes Yes — — — — —
Mobile IAP (RevenueCat) Yes — — — — — —
Web payments (Stripe) Yes — Yes Yes Yes Yes Yes
Auth with RBAC Better-Auth NextAuth Email/OAuth NextAuth NextAuth Multi Multi
Background jobs Inngest — Wasp Jobs — — Partial Partial
OpenTelemetry tracing Yes — — — — — —
Feature flags PostHog — — — — — —
Canary rollouts Edge Config — — — — — —
Rate limiting Upstash — — — — — —
Email templates React Email — — — Partial Yes Yes
Error tracking Sentry — — — — — —
Analytics PostHog — Plausible — — — —
CI/CD GH Actions — — — — — —

Key differentiators:

  • Web + Mobile in one repo — the only open-source template with a full Expo app (auth flows, tab navigation, subscription paywall) alongside a Next.js dashboard
  • Dual payment rails — Stripe for web + RevenueCat for iOS/Android IAP, both with webhook handlers
  • Production observability — Sentry + OpenTelemetry + PostHog + Edge Config canary rollouts, all pre-wired
  • Event-driven architecture — Inngest functions for welcome emails, payment failures, and scheduled cleanup with built-in retries

Project structure

apps/
  web/          Next.js 16 — dashboard, auth, billing, admin panel
  mobile/       Expo Router — iOS & Android with NativewindUI
packages/
  db/           @repo/db — Drizzle ORM schema + migrations
  email/        @repo/email — React Email templates
  shadcn-ui/    @repo/shadcn-ui — web UI components
  nativewindui/ @repo/nativewindui — mobile UI components
  typescript-config/  shared tsconfig presets
  eslint-config/      shared ESLint rules

Quick start

Prerequisites

  • Node.js >= 20
  • pnpm >= 10.32
  • PostgreSQL — local or hosted (Supabase, Neon, Railway, …)

Setup

# 1. Clone and run the setup script
pnpm setup

# 2. Fill in .env.local (the script creates it from .env.example)
#    Minimum required: DATABASE_URL, BETTER_AUTH_SECRET

# 3. Run migrations
pnpm db:migrate

# 4. Start all apps
pnpm dev

Web → http://localhost:3003 Mobile → cd apps/mobile && pnpm dev (Expo Go / simulator)

Environment variables

Copy .env.example to .env.local and fill in your credentials.

Minimum to run locally:

Variable Where to get it
DATABASE_URL Supabase → Settings → Database → Connection string
BETTER_AUTH_SECRET openssl rand -hex 32
NEXT_PUBLIC_APP_URL http://localhost:3003

Everything else (Stripe, RevenueCat, Sentry, …) is optional locally — the app degrades gracefully when services are unconfigured.

Commands

pnpm setup            # First-time setup (install + .env.local + migration hint)
pnpm dev              # Start all apps
pnpm build            # Build all packages + apps
pnpm lint             # Lint everything
pnpm typecheck        # TypeScript check
pnpm test             # Vitest (web)

# Database
pnpm db:generate      # Generate Drizzle migrations from schema changes
pnpm db:migrate       # Apply migrations to the database
pnpm db:push          # Push schema directly (dev, no migration file)
pnpm db:studio        # Open Drizzle Studio

Features walkthrough

Authentication (Better-Auth)

  • Email + password sign-up / sign-in
  • Admin RBAC via admin() plugin — role management at /admin
  • Middleware protects /dashboard/** and /admin/**
  • Mobile uses HTTP-based auth with AsyncStorage session

Payments

  • Web (Stripe): checkout session → subscription → billing portal
  • Mobile (RevenueCat): wraps Apple StoreKit + Google Play Billing
  • Webhook handlers for both at /api/webhooks/stripe and /api/webhooks/revenuecat

Database

5 tables managed with Drizzle ORM: users, user_subscriptions, payments, mobile_subscriptions, mobile_payments

Background jobs (Inngest)

Function Trigger
send-welcome-email user/signup event
payment-failed-reminder stripe/payment.failed event
subscription-canceled stripe/subscription.canceled event
cleanup-sessions Cron — daily 3 AM UTC

Observability

  • Sentry — error boundaries + exception capture
  • PostHog — analytics + feature flags (server + client)
  • OpenTelemetry — OTLP trace export, 10% sample rate in prod
  • Vercel Edge Config — canary rollouts + kill switches (<1ms reads)

Deployment

Web (Vercel)

  1. Import repo → Vercel auto-detects Next.js
  2. Set environment variables from .env.example
  3. Link an Edge Config store (optional, for canary rollouts)

Mobile (EAS Build)

cd apps/mobile
eas build --platform all   # Production builds
eas submit                 # Submit to App Store + Play Store

CI automatically builds on v* git tags via .github/workflows/mobile.yml.

Documentation

Contributing

We welcome contributions! Check out CONTRIBUTING.md to get started.

Looking for something to work on? Browse issues labeled good first issue or help wanted.

Support the project

If this template saved you time, consider supporting its development:

License

MIT — see LICENSE for details.