MantleKit integrates with several third-party services. This guide covers setting up each one in detail, including common pitfalls and troubleshooting tips.
Database (Supabase)
Supabase provides a hosted PostgreSQL database with built-in auth, real-time subscriptions, and a generous free tier (500MB storage, 50,000 monthly active users).
Creating Your Project
- Sign up at supabase.com — the free tier is more than enough to get started
- Click New Project and choose a name, database password, and region (pick the one closest to your users)
- Wait for the project to provision (usually under a minute)
Finding Your API Keys
Go to Project Settings → API (or Data API on newer dashboards):
- Project URL — looks like
https://<project-id>.supabase.co. This is yourNEXT_PUBLIC_SUPABASE_URL - Anon/Publishable Key — safe for client-side use. This is your
NEXT_PUBLIC_SUPABASE_ANON_KEY - Service Role Key — has full access, bypasses RLS. Keep this secret and server-side only. This is your
SUPABASE_SERVICE_ROLE_KEY
All three are on the same page. You may need to click "Reveal" for the service role key.
You should also set:
NEXT_PUBLIC_SITE_URLto your final public domain, for examplehttps://yourdomain.com
This keeps MantleKit's canonical URLs, Open Graph tags, and transactional links pointing at the correct site.
Running the Database Setup
MantleKit includes a unified SQL script that creates all required tables:
- In Supabase Dashboard, go to SQL Editor
- Open
supabase/setup.sqlfrom your project - Paste the entire contents and click Run
This creates:
subscriptionstable with RLS policieswebhook_eventstable for idempotencyproductsandorderstables for ecommercelicence_keystable for CLI download gatingblog_comments,blog_comment_votes, andblog_likestables for blog social featuresprofilesadmin rolesteams,team_memberships, andcalendar_eventsfor internal workspacescomment_moderation_settingsfor configurable comment review rulesanalytics_eventsfor the lightweight analytics dashboard- 5 example seed products
The script is idempotent — you can run it multiple times safely.
Configuring URL Redirects
This step is critical for auth to work in production:
- Go to Authentication → URL Configuration
- Set Site URL to your production domain (e.g.
https://yourdomain.com) - Under Redirect URLs, add:
https://yourdomain.com/**(production)http://localhost:3000/**(local development)
Without this, confirmation emails and OAuth logins will redirect to localhost instead of your live site.
Email Templates
Supabase sends confirmation and password reset emails using built-in templates. To customise them:
- Go to Authentication → Email Templates
- Edit the Confirm Signup and Reset Password templates
- The
{{ .ConfirmationURL }}variable uses the Site URL you configured above
For production, consider setting up a custom SMTP server in Project Settings → Auth → SMTP Settings so emails come from your domain instead of Supabase's default sender.
Authentication
MantleKit supports multiple auth methods via Supabase Auth. Enable them in your Supabase Dashboard under Authentication → Providers.
Email/Password
Enabled by default in most Supabase projects. Users sign up with an email and password, then receive a confirmation email. No additional setup required beyond configuring your Site URL (see above).
Google OAuth
Google OAuth lets users sign in with their Google account in one click.
Step 1: Create Google OAuth Credentials
- Go to Google Cloud Console
- Create a new project (or select an existing one)
- Navigate to APIs & Services → Credentials
- Click Create Credentials → OAuth client ID
- Select Web application as the application type
- Under Authorized redirect URIs, add:
Replacehttps://<your-project>.supabase.co/auth/v1/callback<your-project>with your Supabase project reference ID. - Click Create and note the Client ID and Client Secret
Step 2: Configure OAuth Consent Screen
If prompted, configure the OAuth consent screen:
- Go to APIs & Services → OAuth consent screen
- Choose External user type
- Fill in the required fields: App name, user support email, developer email
- Add scopes:
emailandprofile - Save — you don't need to submit for verification unless you're launching to more than 100 users
Step 3: Enable in Supabase
- In Supabase Dashboard → Authentication → Providers → Google
- Toggle Google on
- Paste in your Client ID and Client Secret
- Save
Step 4: Verify in MantleKit
Make sure google: true is set in mantle.config.ts under authMethods:
authMethods: {
emailPassword: true,
google: true,
github: true,
},GitHub OAuth
GitHub OAuth is a great fit for dev-focused products and agencies.
Step 1: Create a GitHub OAuth App
- Go to GitHub Developer Settings
- Click OAuth Apps → New OAuth App
- Fill in:
- Application name — your product name
- Homepage URL — your production site
- Authorization callback URL:
https://<your-project>.supabase.co/auth/v1/callback
- Click Register application
- Copy the Client ID
- Generate and copy a Client Secret
Step 2: Enable in Supabase
- In Supabase Dashboard → Authentication → Providers → GitHub
- Toggle GitHub on
- Paste in your Client ID and Client Secret
- Save
Step 3: Verify in MantleKit
Make sure github: true is set in mantle.config.ts under authMethods.
Troubleshooting Auth
- Confirmation email links to localhost — Update your Site URL in Supabase (see Database section above)
- Google login shows "Error 400: redirect_uri_mismatch" — Double-check the authorized redirect URI in Google Cloud Console matches your Supabase callback URL exactly
- "Provider not enabled" error — The auth method isn't toggled on in Supabase Authentication → Providers
- GitHub login isn't showing — Make sure
github: trueis enabled inmantle.config.tsand the GitHub provider is toggled on in Supabase
AI Chat
MantleKit includes a dashboard AI assistant. It supports three providers:
- OpenAI
- Anthropic
- OpenRouter
The AI assistant lives inside the admin dashboard and uses your configured provider plus a MantleKit-aware system prompt so it understands the current project setup better than a blank chatbot shell.
Required Environment Variables
The two most important variables are:
AI_PROVIDER=openai
AI_MODEL=gpt-4.1-miniThen add the API key for the provider you want to use.
OpenAI
OpenAI is the default provider. If you do not set AI_PROVIDER, MantleKit falls back to OpenAI automatically.
AI_PROVIDER=openai
OPENAI_API_KEY=your-openai-api-key
AI_MODEL=gpt-4.1-miniIf you omit AI_MODEL, MantleKit still defaults to a sensible OpenAI model.
Anthropic
To use Anthropic:
AI_PROVIDER=anthropic
ANTHROPIC_API_KEY=your-anthropic-api-key
AI_MODEL=claude-sonnet-4-5If you omit AI_MODEL, MantleKit defaults to claude-sonnet-4-5 for Anthropic.
OpenRouter
To use OpenRouter:
AI_PROVIDER=openrouter
OPENROUTER_API_KEY=your-openrouter-api-key
AI_MODEL=openai/gpt-4.1-miniIf you omit AI_MODEL, MantleKit uses a sensible OpenRouter default.
Where To Add These
Add the AI variables to your local environment file:
.env.localFor production, add the same variables to your hosting platform environment settings.
How MantleKit Chooses A Provider
The logic is simple:
- If
AI_PROVIDER=anthropic, it usesANTHROPIC_API_KEY - If
AI_PROVIDER=openrouter, it usesOPENROUTER_API_KEY - Otherwise, it uses OpenAI and expects
OPENAI_API_KEY
If the provider is set correctly but the matching API key is missing, the dashboard AI will fail with a provider key error.
Troubleshooting AI Chat
- AI chat says the provider key is missing — You set
AI_PROVIDER, but not the matching API key - You only set
OPENAI_API_KEY— That is fine; OpenAI is the default provider - Anthropic isn't being used — Make sure
AI_PROVIDER=anthropic, not justANTHROPIC_API_KEY - OpenRouter isn't being used — Make sure
AI_PROVIDER=openrouter - The model name seems ignored — Check
AI_MODELspelling and restart your dev server after changing env vars
Payment Providers
MantleKit supports three payment providers. You choose one during setup via the CLI. All three charge per-transaction only — there are no monthly fees.
Stripe
Stripe is the most widely used payment provider and the recommended default.
Setting Up Stripe
- Create a Stripe account — start in test mode
- Go to Developers → API keys to find your Secret Key (
sk_test_...) - Create products and prices matching your tiers:
- Go to Products → Add product
- Create a product for each tier with the appropriate price
- Note the Price ID (
price_...) for each
Setting Up Webhooks
Webhooks let Stripe notify your app when payments succeed, subscriptions change, etc.
- Go to Developers → Webhooks → Add endpoint
- Set the endpoint URL to
https://yourdomain.com/api/webhooks/stripe - Select these events:
checkout.session.completedcustomer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedinvoice.payment_succeededinvoice.payment_failed
- Click Add endpoint and copy the Signing Secret (
whsec_...)
Environment Variables
Add to your .env.local:
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...Configuration
Update mantle.config.ts with your actual Stripe price IDs:
stripePriceIds: {
monthly: "price_abc123",
yearly: "price_def456",
},Going Live
When you're ready for production:
- Toggle off test mode in the Stripe dashboard
- Replace test API keys with live keys in your environment variables
- Create a new webhook endpoint with your production URL
- Update the webhook secret in your environment
Lemon Squeezy
Lemon Squeezy is a merchant of record — they handle tax, compliance, and billing on your behalf.
- Create a Lemon Squeezy account
- Create a Store and add your products
- Get your API key from Settings → API
- Set up a webhook:
- Go to Settings → Webhooks
- Endpoint URL:
https://yourdomain.com/api/webhooks/lemon-squeezy - Select relevant events (subscription created, updated, cancelled)
- Add to your environment:
LEMONSQUEEZY_API_KEY=your-api-key LEMONSQUEEZY_STORE_ID=your-store-id LEMONSQUEEZY_WEBHOOK_SECRET=your-webhook-secret
Polar
Polar is designed for open source and developer tools.
- Create a Polar account
- Create an organisation and add your products
- Get your Access Token from Settings
- Set up a webhook:
- Endpoint URL:
https://yourdomain.com/api/webhooks/polar
- Endpoint URL:
- Add to your environment:
POLAR_ACCESS_TOKEN=your-access-token POLAR_WEBHOOK_SECRET=your-webhook-secret POLAR_ORGANIZATION_ID=your-org-id
Testing Payments Locally
To test webhooks locally during development, use a tunnel to expose your local server:
# Using cloudflared (free, no account needed)
cloudflared tunnel --url http://localhost:3000This gives you a temporary public URL. Use it as your webhook endpoint in test mode.
Email Providers
MantleKit uses email for transactional messages: welcome emails, password resets, purchase confirmations, and contact form submissions. Both providers offer generous free tiers.
Resend
Resend offers 3,000 emails/month free — enough for most projects.
- Create a Resend account
- Go to Domains → Add Domain
- Add the DNS records Resend provides (usually a TXT and MX record) to your DNS provider
- Wait for verification (can take a few minutes to an hour)
- Get your API key from API Keys → Create API Key
- Add to your environment:
RESEND_API_KEY=re_... - Update
mantle.config.ts:emailProvider: "resend", email: { from: "YourApp <noreply@yourdomain.com>", contactTo: "support@yourdomain.com", },
Mailgun
Mailgun offers 1,000 emails/month free.
- Create a Mailgun account
- Go to Sending → Domains → Add New Domain
- Add the DNS records Mailgun provides
- Wait for domain verification
- Get your API key from Settings → API Keys
- Add to your environment:
MAILGUN_API_KEY=your-api-key MAILGUN_DOMAIN=mg.yourdomain.com
Brevo (formerly Sendinblue)
Brevo offers 300 emails/day free (~9,000/month) — the most generous free tier for transactional email.
- Create a Brevo account
- Go to Settings → SMTP & API → API Keys
- Create a new API key
- Add and verify your sending domain under Settings → Senders & Domains
- Add to your environment:
BREVO_API_KEY=xkeysib-... - Set in
mantle.config.ts:emailProvider: "brevo",
Email Not Arriving?
- Check spam/junk folders — new sending domains often trigger spam filters initially
- Verify DNS records — all providers show verification status in their dashboard
- Check the "from" address — it must match your verified domain
- Review Supabase SMTP — if auth emails aren't arriving, set up custom SMTP in Supabase using your email provider's credentials
Chat Support
MantleKit supports Tawk.to for the public chat widget. Configure it in mantle.config.ts and the widget appears automatically on all pages.
Tawk.to (100% Free)
Tawk.to is completely free — no paid tiers, no per-seat charges, unlimited agents.
- Create a Tawk.to account
- Add your website as a new property
- Go to Administration → Channels → Chat Widget
- Find your embed script — it contains your Property ID and Widget ID in the URL:
For example:https://embed.tawk.to/PROPERTY_ID/WIDGET_IDhttps://embed.tawk.to/69c91f1e0330fc1c37baef53/1jksq343q - Set in
mantle.config.ts:tawkPropertyId: "69c91f1e0330fc1c37baef53", tawkWidgetId: "1jksq343q",
Make sure both Tawk identifiers are set together so the widget can load correctly.
Hosting (Vercel)
Vercel is the recommended hosting platform. Their free Hobby plan is enough for most projects.
Initial Deployment
- Push your project to a Git repository (GitHub, GitLab, or Bitbucket)
- Go to vercel.com/new
- Import your repository
- Vercel auto-detects Next.js — no custom build configuration needed
- Click Deploy
Environment Variables
Before your first deploy (or immediately after), add all required environment variables:
- Go to your project → Settings → Environment Variables
- Add each variable from your
.env.localfile - Make sure to set them for Production, Preview, and Development as needed
At minimum you need:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEYSUPABASE_SERVICE_ROLE_KEY- Your payment provider keys
- Your email provider API key
Custom Domain
- Go to Settings → Domains
- Add your domain name
- Vercel will show you the DNS records to add:
- A record:
@→76.76.21.21 - CNAME record:
www→cname.vercel-dns.com
- A record:
- Add these records in your DNS provider (or Vercel if they manage your DNS)
- SSL certificates are provisioned automatically once DNS propagates
DNS propagation can take anywhere from a few minutes to a few hours. If you see a certificate error, wait and try again.
Continuous Deployment
Every push to your main branch triggers an automatic production deployment. Pull requests get preview deployments with unique URLs — great for testing changes before merging.
Troubleshooting Vercel
- Build fails with
ECONNRESET— Transient network error. Just click Redeploy - Environment variable not found — Make sure it's added for the correct environment (Production vs Preview)
- DNS certificate error — Wait for DNS propagation. Try removing and re-adding the domain if it persists
npm warn deprecated— These are warnings from transitive dependencies, not errors. They won't affect your build
Alternative Hosting
While Vercel is recommended, MantleKit works on any platform that supports Node.js:
- Railway — Simple deploy from Git, $5/month hobby plan
- Fly.io — Edge deployment, free tier available
- DigitalOcean App Platform — From $5/month
- AWS Amplify — If you're already in the AWS ecosystem
- Self-hosted — Run
next build && next starton any Node.js server
For non-Vercel platforms, you may need to configure build commands and output directories manually. The default Next.js settings (next build, .next output) work everywhere.