Documentation
Getting StartedEnvironment Setup

Environment Setup

Configure your environment variables and application settings

This guide walks you through configuring all the necessary environment variables and application settings for Sushify Next.js.

Environment Variables

Sushify Next.js uses environment variables to configure external services and application behavior. All environment variables should be defined in a .env.local file at the root of your project.

Copy the Example File

Copy the example environment file and configure your variables:

cp .env.local.example .env.local

Database Configuration

Configure your database connection. Sushify Next.js uses PostgreSQL with Prisma ORM:

.env.local
# Database
DATABASE_URL="postgresql://user:password@host:port/database"
DIRECT_URL="postgresql://user:password@host:port/database"
  • DATABASE_URL: Connection string used for queries (supports connection pooling)
  • DIRECT_URL: Direct connection string for migrations (bypasses connection pooling, required for Supabase)

Recommended Providers: Supabase, Neon, Railway, or local PostgreSQL.

See the Database documentation for detailed setup instructions, ORM configuration, and schema information.

Mail Provider

Sushify Next.js supports multiple email service providers. You need to:

  1. Choose a provider and configure it in config/index.ts
  2. Set the required environment variables for that provider

Step 1: Configure Provider in config/index.ts

Open config/index.ts and update the mails section:

// Mails
mails: {
  // Can be: resend, mailgun, postmark, plunk, nodemailer, console, custom
  provider: "resend", // Change this to your chosen provider
  // The from address for emails
  from: "noreply@yourdomain.com", // Change this to your verified email
},

Step 2: Set Environment Variables

Based on your chosen provider, add the corresponding environment variables to .env.local:

Resend is a modern email API designed for developers.

RESEND_API_KEY="re_xxxxxxxxxxxx"

Getting your API key:

  1. Sign up at resend.com
  2. Verify your domain or use their test domain for development
  3. Go to API Keys section and create a new API key
Option 2: Mailgun

Mailgun is a powerful transactional email service.

MAILGUN_API_KEY="your-mailgun-api-key"
MAILGUN_DOMAIN="mg.yourdomain.com"

Getting your credentials:

  1. Sign up at mailgun.com
  2. Add and verify your domain
  3. Find your API key in Settings → API Keys
  4. Use your verified domain (e.g., mg.yourdomain.com)
Option 3: Postmark

Postmark focuses on transactional emails with high deliverability.

POSTMARK_SERVER_TOKEN="your-postmark-server-token"

Getting your server token:

  1. Sign up at postmarkapp.com
  2. Create a new server
  3. Find your Server API Token in the server settings
Option 4: Plunk

Plunk is a simple email API service.

PLUNK_API_KEY="your-plunk-api-key"

Getting your API key:

  1. Sign up at useplunk.com
  2. Navigate to Settings → API Keys
  3. Create a new API key
Option 5: Nodemailer (SMTP)

Use any SMTP server with Nodemailer. Good for custom mail servers or services like Gmail, SendGrid SMTP, etc.

MAIL_HOST="smtp.example.com"
MAIL_PORT="587"
MAIL_USER="your-email@example.com"
MAIL_PASS="your-password-or-app-password"

Configuration examples:

  • Gmail: Use smtp.gmail.com, port 587, and an App Password
  • SendGrid: Use smtp.sendgrid.net, port 587, and apikey as username with your API key as password
  • Custom SMTP: Use your server's SMTP settings
Option 6: Console (Development Only)

For development, you can use the console provider which logs emails to the terminal instead of sending them:

// In config/index.ts
mails: {
  provider: "console",
  from: "dev@localhost.com",
},

No environment variables needed. Emails will be printed to your terminal.

Authentication Configuration

Configure authentication providers and settings:

# Authentication
BETTER_AUTH_SECRET="A_RANDOM_SECRET_STRING"

# OAuth Providers (Optional)
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"

GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"

Generate a secure BETTER_AUTH_SECRET:

openssl rand -base64 32

See the Authentication documentation for OAuth provider setup.

Payment Provider

Sushify Next.js supports multiple payment service providers. You need to:

  1. Choose a provider and configure it in config/index.ts
  2. Set the required environment variables for that provider

Step 1: Configure Provider in config/index.ts

Open config/index.ts and update the payments section:

config/index.ts
// Payments
payments: {
  // Can be: stripe, lemonsqueezy, polar, dodopayments
  provider: "stripe", // Change this to your chosen provider
},

Step 2: Set Environment Variables

Based on your chosen provider, add the corresponding environment variables to .env.local:

Stripe is a comprehensive payment platform with extensive features.

.env.local
# Stripe
STRIPE_SECRET_KEY="sk_test_..."
STRIPE_WEBHOOK_SECRET="whsec_..."

# Product/Price IDs
NEXT_PUBLIC_PRICE_ID_PRO_MONTHLY="price_..."
NEXT_PUBLIC_PRICE_ID_PRO_YEARLY="price_..."
NEXT_PUBLIC_PRICE_ID_LIFETIME="price_..."

Getting your credentials:

  1. Sign up at stripe.com
  2. Get your API keys from Dashboard → Developers → API keys
  3. Set up webhooks and get the webhook secret
  4. Create products and copy their price IDs

See the Stripe Integration guide for detailed setup.

Option 2: Lemon Squeezy

Lemon Squeezy is a merchant of record platform that handles taxes and compliance.

.env.local
LEMONSQUEEZY_API_KEY="your-lemonsqueezy-api-key"
LEMONSQUEEZY_WEBHOOK_SECRET="your-webhook-secret"
LEMONSQUEEZY_STORE_ID="your-store-id"

Getting your credentials:

  1. Sign up at lemonsqueezy.com
  2. Navigate to Settings → API to create an API key
  3. Find your Store ID in Settings → Stores
  4. Configure webhooks and get the webhook secret
Option 3: Polar

Polar is a payment platform built for developers and creators.

.env.local
POLAR_ACCESS_TOKEN="your-polar-access-token"
POLAR_WEBHOOK_SECRET="your-webhook-secret"

Getting your credentials:

  1. Sign up at polar.sh
  2. Generate an access token in your account settings
  3. Configure webhooks and get the webhook secret
Option 4: DodoPayments

DodoPayments is a simple payment solution.

.env.local
DODO_PAYMENTS_API_KEY="your-dodopayments-api-key"

Getting your API key:

  1. Sign up at dodopayments.com
  2. Navigate to API settings to create an API key

Analytics Provider

Sushify Next.js supports multiple analytics providers to track user behavior and application metrics. You need to:

  1. Choose a provider and configure it in config/index.ts
  2. Set the required environment variables for that provider

Step 1: Configure Provider in config/index.ts

Open config/index.ts and update the analytics section:

config/index.ts
// Analytics
analytics: {
  // Can be: pirsch, plausible, mixpanel, googleanalytics
  provider: "plausible", // Change this to your chosen provider
},

Step 2: Set Environment Variables

Based on your chosen provider, add the corresponding environment variables to .env.local:

Option 1: Pirsch

Pirsch is a privacy-friendly analytics solution with no cookies.

.env.local
NEXT_PUBLIC_PIRSCH_CODE="your-pirsch-code"

Getting your code:

  1. Sign up at pirsch.io
  2. Create a new website
  3. Copy the identification code from your dashboard

Plausible is a lightweight, open-source, and privacy-friendly analytics platform.

.env.local
NEXT_PUBLIC_PLAUSIBLE_URL="https://plausible.io"

Getting started:

  1. Sign up at plausible.io or self-host
  2. Add your website domain
  3. Use the default URL or your self-hosted URL
Option 3: Mixpanel

Mixpanel provides advanced product analytics and user behavior tracking.

.env.local
NEXT_PUBLIC_MIXPANEL_TOKEN="your-mixpanel-token"

Getting your token:

  1. Sign up at mixpanel.com
  2. Create a new project
  3. Find your project token in Project Settings
Option 4: Google Analytics

Google Analytics is a comprehensive web analytics service by Google.

.env.local
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID="G-XXXXXXXXXX"

Getting your measurement ID:

  1. Sign up at analytics.google.com
  2. Create a new property
  3. Set up a data stream for your website
  4. Copy the Measurement ID (starts with "G-")

AI Integration

If you're using AI features in your application, configure your AI provider:

.env.local
# OpenAI
OPENAI_API_KEY="sk-..."

Getting your API key:

  1. Sign up at openai.com
  2. Navigate to API keys section
  3. Create a new API key
  4. Set usage limits and billing as needed

Affiliate Integration

Sushify Next.js supports affiliate programs with Rewardful and PromoteKit. You need to:

  1. Enable and configure the affiliate provider in config/index.ts
  2. Set the required environment variables for that provider

Important: Affiliate functionality requires Stripe as your payment provider. Make sure you have configured Stripe in step 5 above.

Step 1: Configure Affiliate Provider in config/index.ts

Open config/index.ts and update the affiliate section:

config/index.ts
// Affiliate
affiliate: {
  // whether the affiliate program should be enabled
  enabled: true,
  // the provider of the affiliate program
  // Can be: rewardful, promotekit
  provider: "rewardful", // Change this to your chosen provider
},

Step 2: Set Environment Variables

Based on your chosen provider, add the corresponding environment variables to .env.local:

Option 1: Rewardful

Rewardful is a powerful affiliate tracking platform for SaaS businesses.

.env.local
REWARDFUL_API_KEY="your-rewardful-api-key"
REWARDFUL_API_SECRET="your-rewardful-api-secret"

Getting your credentials:

  1. Sign up at getrewardful.com
  2. Connect your Stripe account
  3. Navigate to Settings → API to get your API key and secret
  4. Configure your commission structure and affiliate terms
Option 2: PromoteKit

PromoteKit is an affiliate management solution designed for modern SaaS.

.env.local
PROMOTEKIT_API_KEY="your-promotekit-api-key"

Getting your API key:

  1. Sign up at promotekit.com
  2. Connect your Stripe account
  3. Navigate to Settings → API Keys to create an API key
  4. Set up your affiliate program rules and commissions