Getting Started
Copy the example environment file to get started:Use
.env.local for local development and configure environment variables through your hosting platform for production deployments.Core Configuration
Application
Basic application configuration:Database
PostgreSQL connection string:postgresql://- Database protocolpostgres:postgres- Username:password@localhost:5432- Host:port/mantlz- Database name?schema=public- Prisma schema
Using Docker Compose database
Using Docker Compose database
When using the included Docker Compose setup, the database URL should reference the service name:
Using managed database services
Using managed database services
For managed databases (Neon, Supabase, PlanetScale, etc.), use the connection string provided by your service:
Authentication (Clerk)
Mantlz uses Clerk for authentication and user management.Required Variables
Clerk URL Configuration
Create a Clerk application
- Go to clerk.com and sign up
- Create a new application
- Choose your authentication methods (Email, Google, GitHub, etc.)
Get your API keys
From your Clerk dashboard:
- Navigate to API Keys
- Copy the Publishable Key (starts with
pk_) - Copy the Secret Key (starts with
sk_)
See the Clerk Integration section for detailed setup instructions.
Payment Processing (Stripe)
Mantlz uses Stripe for subscription billing and payment processing.Required Variables
Getting Your Stripe Keys
Create a Stripe account
Sign up at stripe.com
Get API keys
- Navigate to Developers → API Keys
- Copy your Secret key (starts with
sk_test_for test mode) - Note: Publishable key is not required for Mantlz
Create subscription products
- Go to Products → Create product
- Create “Standard” and “Pro” plans
- Set up recurring pricing
- Copy each price ID (starts with
price_)
Configure webhook secret
See the Webhooks Guide for detailed webhook setup.
Email Service (Resend)
Mantlz uses Resend for transactional emails.Sign up for Resend
Create an account at resend.com
Content Management (Sanity)
Sanity CMS is used for blog posts and marketing content.If you’re not using Sanity CMS, these variables can be left as defaults. The application will still function without Sanity content.
Rate Limiting (Upstash Redis)
Optional rate limiting using Upstash Redis:Setting up Upstash Redis
Setting up Upstash Redis
- Create an account at upstash.com
- Create a new Redis database
- Select a region close to your deployment
- Copy the REST URL and token from the database details
- Add to your environment variables
Rate limiting is automatically disabled if
UPSTASH_REDIS_REST_URL is not set. The application will function without rate limiting.Analytics (PostHog)
Optional product analytics with PostHog:Error Tracking (Sentry)
Optional error tracking with Sentry:Setting up Sentry
Setting up Sentry
- Create a project at sentry.io
- Select Next.js as the platform
- Copy the DSN from the project settings
- Add to your environment variables
sentry.edge.config.tssentry.server.config.ts
File Uploads (Uploadcare)
Optional file upload service:Cron Jobs
For scheduled tasks (campaigns, quota resets):Complete Example
Here’s a complete.env.local file for development:
.env.local
Production Checklist
Before deploying to production:- Update
NEXT_PUBLIC_APP_URLto your production domain - Use production Stripe keys (start with
sk_live_) - Use production Clerk keys (start with
pk_live_andsk_live_) - Set
NODE_ENV="production" - Configure a production database
- Set up Stripe webhooks with production webhook secret
- Configure proper email domain with Resend
- Generate a secure
CRON_SECRET - Set up error tracking with Sentry
- Enable rate limiting with Upstash Redis
Troubleshooting
Environment variables not loading
Environment variables not loading
- Ensure the file is named exactly
.env.local - Restart your development server after changing environment variables
- For Docker, rebuild the container:
docker compose up --build - Check for syntax errors (no spaces around
=)
NEXT_PUBLIC_ variables not accessible in browser
NEXT_PUBLIC_ variables not accessible in browser
Variables prefixed with
NEXT_PUBLIC_ are embedded at build time. If you change these variables:- Restart the dev server:
npm run dev - Or rebuild for production:
npm run build
Database connection fails
Database connection fails
- Verify PostgreSQL is running
- Check the connection string format
- Ensure the database exists
- Check firewall rules for remote databases
- Run migrations:
npx prisma migrate deploy
Next Steps
Integrations
Set up Stripe, Clerk, and other third-party services
Webhooks
Configure webhook endpoints
Self-Hosting
Deploy Mantlz with Docker
API Reference
Explore the API