A production-ready SaaS starter kit built with Next.js and Postrust (PostgREST in Rust). All business logic lives in PostgreSQL with Row Level Security (RLS) for authorization.
- Authentication: Magic link (email) + OAuth (Google, GitHub) via NextAuth.js
- Team Management: Create teams, invite members, manage roles
- Billing: Stripe + LemonSqueezy integration ready
- Projects: Demo feature showing team-scoped resources
- API Keys: Generate and manage API keys
- Audit Logs: Track all team actions
- Row Level Security: Secure data access at the database level
| Layer | Technology |
|---|---|
| Frontend | Next.js 14, React 18, TypeScript |
| Styling | Tailwind CSS, shadcn/ui |
| Auth | NextAuth.js v5 |
| API | Postrust (PostgREST in Rust) |
| Database | PostgreSQL 16+ |
| Payments | Stripe |
| Monorepo | Turborepo |
- Node.js 18+
- Docker & Docker Compose
- pnpm (recommended)
- Clone the repository:
git clone https://github.com/your-username/postrust-saas-starter.git
cd postrust-saas-starter- Install dependencies:
pnpm install- Copy the environment file:
cp .env.example .env- Start the development stack:
docker-compose up -d- Run database migrations:
# Connect to postgres and run migrations
docker exec -i postgres psql -U postgres -d saas_starter < packages/database/migrations/001_initial_schema.sql
docker exec -i postgres psql -U postgres -d saas_starter < packages/database/migrations/002_rls_policies.sql
docker exec -i postgres psql -U postgres -d saas_starter < packages/database/migrations/003_functions.sql
docker exec -i postgres psql -U postgres -d saas_starter < packages/database/migrations/004_seed_plans.sql- Start the development server:
pnpm devOpen http://localhost:3000 to see the app.
postrust-saas-starter/
├── apps/
│ └── web/ # Next.js application
│ ├── app/
│ │ ├── (auth)/ # Auth pages (login, register)
│ │ ├── (dashboard)/ # Protected dashboard
│ │ ├── (marketing)/ # Public pages
│ │ └── api/ # API routes
│ ├── components/
│ │ └── ui/ # shadcn/ui components
│ └── lib/
│ ├── api.ts # Postrust API client
│ ├── auth.ts # NextAuth config
│ └── utils.ts # Utilities
├── packages/
│ └── database/
│ └── migrations/ # SQL migrations
├── docker/
│ └── docker-compose.yml # Local dev stack
└── package.json
See .env.example for all required environment variables:
POSTRUST_URL- Postrust API URLPOSTRUST_JWT_SECRET- JWT secret for API authenticationNEXTAUTH_SECRET- NextAuth.js secret- OAuth credentials (Google, GitHub)
- Stripe/LemonSqueezy API keys
The database uses PostgreSQL with the following core tables:
users- User accounts (synced from NextAuth)teams- Team/organization entitiesteam_members- Team membership with rolesinvitations- Pending team invitationssubscriptions- Billing subscriptionsplans- Subscription plansprojects- Demo team-scoped resourceapi_keys- API key managementaudit_logs- Action tracking
All tables are protected with Row Level Security (RLS) policies.
- User signs in via OAuth or magic link
- NextAuth creates/updates user in database via Postrust
- JWT token is generated with user_id claim
- All Postrust requests include JWT for authorization
- RLS policies filter data based on
auth.uid()
- Deploy Next.js to Vercel
- Deploy Postrust + PostgreSQL to Railway
- Configure environment variables
docker-compose -f docker-compose.prod.yml up -dMIT