Local Development Setup
This guide walks you through setting up Terra for local development.Prerequisites
Node.js 18+ installed
pnpm 9+ installed (
npm install -g pnpm)Git configured
A Supabase project (free tier works)
A WorkOS account (free tier: 1M MAU)
A Doppler account (recommended, for secrets management)
A Resend account (optional, for email testing)
A DeepL account (optional, for auto-translation)
A Smarty Streets account (optional, for address verification)
Quick Start
1
Clone the Repository
2
Install Dependencies
apps/terra- The main Next.js applicationpackages/ui- Shared UI components (@unify/ui)
3
Configure Environment Variables
You have two options for managing environment variables:Running with Doppler:Benefits:Option B: Local
Create a
Option A: Doppler (Recommended)
Doppler provides centralized secrets management with automatic syncing.Setup:The
dev script in apps/terra/package.json is configured as doppler run -- next dev, so secrets are automatically injected.- No
.env.localfile to manage - Automatic sync across team members
- Environment branching (dev/staging/prod)
- Audit logs for secret access
- Automatic secret rotation
Option B: Local .env.local File
Create a .env.local file in apps/terra/:4
Run Database Migrations
Terra uses SQL migration files. Run them in order against your Supabase database.Option A: Supabase DashboardMigration files:
- Go to Supabase Dashboard → SQL Editor
- Run each file in the
apps/terra/migrations/folder in numerical order - Start with
002_add_form_settings.sql, then003_..., etc.
5
Configure WorkOS Redirect
In your WorkOS Dashboard:
- Go to Redirects
- Add
http://localhost:3000/auth/callback - Save
WORKOS_REDIRECT_URI in your .env.local.6
Start the Development Server
Verification Checklist
After setup, verify these features work:| Feature | How to Test |
|---|---|
| Login | Click “Sign In” → WorkOS login → Returns to dashboard |
| Dashboard | / shows metric cards and activity feed |
| Form Builder | Create a form, add fields, save |
| Public Form | Visit /f/your-form-slug |
| Submission | Submit a form → Appears in admin submissions table |
| Email (optional) | Submit a form → Check TEST_EMAIL inbox |
| Translations (optional) | Settings → Localization → Add language → Auto-translate |
| Address Autocomplete (optional) | Add Address field → Type “123 main” → See suggestions |
Running Tests
Common Issues
'Invalid API Key' from Supabase
'Invalid API Key' from Supabase
Double-check your
SUPABASE_SERVICE_ROLE_KEY. It should:- Start with
eyJ... - Be different from the anon key
- Come from Settings → API → service_role key (not anon)
WorkOS Redirect URI Mismatch
WorkOS Redirect URI Mismatch
The error “redirect_uri mismatch” means your
.env.local doesn’t match WorkOS Dashboard.Check that WORKOS_REDIRECT_URI exactly matches what’s in WorkOS → Redirects, including:- Protocol (
http://vshttps://) - Port (
:3000) - Path (
/auth/callback)
Emails Not Sending in Dev
Emails Not Sending in Dev
In development mode, emails are sent via Resend’s test domain to
TEST_EMAIL.Check:RESEND_API_KEYis setTEST_EMAILis your real email address- Check spam folder
File Uploads Failing
File Uploads Failing
Make sure you ran
migrations/004_storage_bucket.sql. This creates the private form-uploads bucket and RLS policies.WORKOS_COOKIE_PASSWORD Error
WORKOS_COOKIE_PASSWORD Error
Project Structure
Previewing Documentation
The docs are built with Mintlify and live inapps/docs/. Mintlify requires Node 20 (LTS), which may differ from your main development Node version.
One-Time Setup
Installfnm (Fast Node Manager) to run Mintlify with the correct Node version:
Running the Docs Server
The
mint alias automatically uses Node 20 and allocates extra memory to prevent crashes when processing large projects.Next: Adding Custom Fields
Learn how to extend the form engine with new field types.