Environment Variables

Configure your AppLighter environment for different database adapters. Set up Mock, Supabase, or PocketBase backends with step-by-step instructions.

Overview

AppLighter uses Vibecode DB with a flexible adapter system that lets you choose your database backend. Configuration is done through environment variables in your .env file.

Quick Setup

Copy the example environment file:

cp .env.example .env

Adapter Selection

Choose your adapter by setting EXPO_PUBLIC_DB_ADAPTER:

# Options: mock, supabase, pocketbase
EXPO_PUBLIC_DB_ADAPTER=mock

Mock Adapter (Default)

The mock adapter provides instant local development with seeded data. No backend setup required - perfect for prototyping and development.

EXPO_PUBLIC_DB_ADAPTER=mock

What happens:

  • Uses an in-memory database with mock data from src/db/seeds/
  • Auto-creates a demo user (alice@example.com / password123)
  • Signs in automatically on app start

Supabase Adapter

Connect to Supabase for cloud PostgreSQL database with built-in authentication.

EXPO_PUBLIC_DB_ADAPTER=supabase
 
# Get these from your Supabase project: Settings > API
EXPO_PUBLIC_SUPABASE_URL=https://your-project-id.supabase.co
EXPO_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

When to use:

  • Production applications with multi-user support
  • Apps requiring real-time sync
  • Applications needing OAuth/social login
  • Team/collaborative features

Setup Steps:

  1. Create a project at supabase.com
  2. Navigate to Settings > API
  3. Copy the Project URL to EXPO_PUBLIC_SUPABASE_URL
  4. Copy the anon/public key to EXPO_PUBLIC_SUPABASE_ANON_KEY

PocketBase Adapter

Connect to PocketBase for a self-hosted, lightweight backend with built-in auth and real-time subscriptions.

EXPO_PUBLIC_DB_ADAPTER=pocketbase
 
# Your PocketBase instance URL
EXPO_PUBLIC_POCKETBASE_URL=http://127.0.0.1:8090

When to use:

  • Self-hosted applications with full data ownership
  • Projects needing a lightweight, single-binary backend
  • Rapid prototyping with a real backend
  • Apps that need to run on-premise or offline-first

Setup Steps:

  1. Download PocketBase from pocketbase.io
  2. Start PocketBase with ./pocketbase serve
  3. Set EXPO_PUBLIC_POCKETBASE_URL to your PocketBase instance URL
  4. Push your schema and seed data using the scripts below

PocketBase Scripts:

AppLighter includes scripts for managing your PocketBase backend:

# Push schema collections to PocketBase
yarn pocketbase-db-push
 
# Seed data to PocketBase
yarn pocketbase-db-seed

These scripts are located in pocketbase/command-scripts/ and use the collection definitions from your project to set up and populate a PocketBase backend.

Environment Variable Reference

VariableRequiredDefaultDescription
EXPO_PUBLIC_DB_ADAPTERNomockDatabase adapter: mock, supabase, or pocketbase
EXPO_PUBLIC_JWT_SECRETFor dev-JWT secret for local auth
EXPO_PUBLIC_SUPABASE_URLFor Supabase-Supabase project URL
EXPO_PUBLIC_SUPABASE_ANON_KEYFor Supabase-Supabase anonymous API key
EXPO_PUBLIC_POCKETBASE_URLFor PocketBase-PocketBase instance URL

How the Adapter System Works

The adapter is selected in src/db/client.ts:

import { createClient } from '@vibecode-db/client'
 
const DB_ADAPTER = process.env.EXPO_PUBLIC_DB_ADAPTER ?? 'mock'
 
// Adapter is chosen based on DB_ADAPTER value:
// - 'mock'       → MockAdapter (in-memory with seeds)
// - 'supabase'   → SupabaseAdapter (cloud PostgreSQL)
// - 'pocketbase' → PocketBaseAdapter (self-hosted backend)

All adapters expose the same Vibecode DB API, so your app code doesn't change when switching adapters.

Security Best Practices

  1. Never commit .env files - They're already in .gitignore
  2. Use strong secrets - Generate with openssl rand -base64 32
  3. Rotate secrets regularly - Especially after team changes
  4. Use different secrets per environment - Dev, staging, production
  5. Store production secrets securely - Use your CI/CD platform's secret management

Next Steps