Skip to content

Configuring Phaset

Phaset is designed to be straightforward to configure while giving you control when you need it. This guide covers everything from the bare minimum to advanced configuration scenarios.

Phaset can be configured in three ways, with priorities from highest to lowest:

  1. CLI flags (e.g., phaset start --port 8080)
  2. Environment variables (e.g., PORT=8080)
  3. Configuration file (phaset.config.json)

This flexibility means you can choose the approach that fits your deployment:

  • Use config files for local development or VMs where you manage files directly
  • Use environment variables for cloud platforms, containers, or CI/CD pipelines
  • Use CLI flags for quick overrides during testing

To run Phaset, you must provide these values:

  • email.host - Your SMTP server hostname
  • email.user - SMTP username (typically your email address)
  • email.password - SMTP password or app-specific password
  • phaset.bootstrap.organizationName - Your organization name
  • phaset.bootstrap.adminEmail - Admin email address (receives first sign-in link)

The configuration file is the most common way to set up Phaset, especially for local development and self-hosted deployments.

Terminal window
phaset init

This creates phaset.config.json in your current directory with a template similar to this:

{
"email": {
"emailSubject": "Sign In To Phaset",
"user": "my_user@my_domain.net",
"password": "my_password",
"host": "smtp.my_host.net",
"port": 465,
"secure": true
},
"auth": {
"jwtSecret": "your-jwt-secret",
"appUrl": "http://localhost:5173/app"
},
"server": {
"allowedDomains": ["*"]
},
"phaset": {
"licenseKey": "",
"bootstrap": {
"organizationName": "My Organization",
"adminEmail": "me@my_domain.net"
}
}
}

Phaset looks for phaset.config.json in your current working directory when you run phaset start. This means you can have different configurations for different deployments by running Phaset from different directories.

Environment variables are ideal for cloud deployments, containers, and CI/CD pipelines where you don’t want to manage configuration files.

Environment VariableDescriptionDefault
EMAIL_HOSTSMTP server hostname-
EMAIL_USERSMTP username-
EMAIL_PASSWORDSMTP password-
EMAIL_PORTSMTP port587
EMAIL_SECUREUse SSL/TLS (true/false)true
EMAIL_SUBJECTSubject line for sign-in emails"Sign In To Phaset"
EMAIL_MAX_RETRIESRetry attempts for failed emails2
Environment VariableDescriptionDefault
AUTH_JWT_SECRETSecret key for JWT signing"your-jwt-secret"
APP_URLURL where users complete sign-in"http://localhost:5173/app"
AUTH_LINK_EXPIRYMagic link expiry in seconds900 (15 min)
AUTH_JWT_EXPIRYJWT token expiry in seconds900 (15 min)
AUTH_REFRESH_EXPIRYRefresh token expiry in seconds604800 (7 days)
AUTH_MAX_SESSIONSMax concurrent sessions per user3
Environment VariableDescriptionDefault
PORTPort to listen on3000
HOSTHost to bind to0.0.0.0
ALLOWED_DOMAINSComma-separated list of allowed CORS origins"http://localhost:5173,http://0.0.0.0:5173"
Environment VariableDescriptionDefault
DATA_DIRDirectory for database filesCurrent directory
STORAGE_KEYEncryption key for sensitive data-
Environment VariableDescriptionDefault
BOOTSTRAP_ORG_NAMEOrganization name for initial setup-
BOOTSTRAP_ADMIN_EMAILAdmin email for initial setup-
PHASET_LICENSE_KEYYour Phaset license key""
DEMO_MODEEnable demo mode (true/false)false
DEBUGEnable debug logging (true/false)false

Example: Cloud Deployment with Environment Variables

Section titled “Example: Cloud Deployment with Environment Variables”

In your App Platform configuration, add these environment variables:

APP_URL=https://phaset.yourcompany.com/app
ALLOWED_DOMAINS=https://phaset.yourcompany.com
BOOTSTRAP_ORG_NAME=Your Company
EMAIL_HOST=smtp.gmail.com
EMAIL_PASSWORD=your-app-password
EMAIL_PORT=465
EMAIL_SECURE=true
AUTH_JWT_SECRET=your-secure-random-string

CLI flags provide the highest priority and are useful for quick overrides during development or testing.

Terminal window
--jwtSecret <secret> JWT secret for token signing
--magicLinkExpirySeconds <seconds> Magic link expiry time
--jwtExpirySeconds <seconds> JWT expiry time
--refreshTokenExpirySeconds <secs> Refresh token expiry time
--maxActiveSessions <number> Max concurrent sessions
--appUrl <url> Application URL for sign-in completion
--debug Enable debug mode (flag, no value)
Terminal window
--emailSubject <subject> Email subject line
--emailHost <hostname> SMTP server hostname
--emailUser <username> SMTP username
--emailPassword <password> SMTP password
--emailPort <port> SMTP port number
--emailSecure Use SSL/TLS (flag, no value)
--emailMaxRetries <number> Max retry attempts
Terminal window
--port <port> Port to listen on
--host <hostname> Host to bind to
--allowed <domain1,domain2,...> Comma-separated allowed domains

Examples of allowed domains:

// Allow specific domains (recommended for production)
"allowedDomains": [
"https://phaset.example.com",
"https://app.example.com"
]
// Allow all domains (development only)
"allowedDomains": ["*"]
// Allow localhost for development
"allowedDomains": [
"http://localhost:5173",
"http://localhost:3000"
]
Terminal window
--db <directory> Database directory path
--encryptionKey <key> Encryption key for storage
Terminal window
--licenseKey <key> Phaset license key
--demoMode Enable demo mode (flag, no value)
--bootstrapOrganizationName <name> Organization name
--bootstrapAdminEmail <email> Admin email address
Terminal window
phaset start --port 8080 --debug
Terminal window
phaset start --emailHost smtp.mailtrap.io --emailPort 2525 --demoMode

When the same setting is provided in multiple ways, Phaset uses this priority order:

  1. CLI flags (highest priority)
  2. Environment variables
  3. Configuration file
  4. Default values (lowest priority)

If you have:

  • Config file: "port": 3000
  • Environment variable: PORT=8080
  • CLI flag: --port 9000

Phaset will use port 9000 (CLI flag wins).

Here’s a fully documented configuration file showing all available options:

{
"email": {
"emailSubject": "Sign In To Phaset",
"user": "[email protected]",
"password": "your-smtp-password",
"host": "smtp.gmail.com",
"port": 465,
"secure": true,
"maxRetries": 2
},
"auth": {
"jwtSecret": "your-secret-key-change-this",
"magicLinkExpirySeconds": 900,
"jwtExpirySeconds": 900,
"refreshTokenExpirySeconds": 604800,
"maxActiveSessions": 3,
"appUrl": "https://phaset.yourcompany.com/app",
"debug": false
},
"server": {
"port": 3000,
"host": "0.0.0.0",
"allowedDomains": [
"https://phaset.yourcompany.com",
"http://localhost:5173"
]
},
"storage": {
"databaseDirectory": "",
"encryptionKey": "",
"debug": false
},
"phaset": {
"licenseKey": "",
"demoMode": false,
"bootstrap": {
"organizationName": "Your Company",
"adminEmail": "[email protected]"
}
}
}

When you start Phaset, it validates your configuration and provides helpful error messages if required fields are missing:

Terminal window
$ phaset start
Error: Missing email.host value
Error: Missing email.user value
Error: Missing email.password value
Error: Missing phaset.bootstrap.organizationName value
Error: Missing phaset.bootstrap.adminEmail value

This ensures you can’t accidentally start Phaset with incomplete configuration.

Goal: Quick setup for testing on your laptop

{
"email": {
"user": "[email protected]",
"password": "test-password",
"host": "smtp.mailtrap.io",
"port": 2525,
"secure": false
},
"auth": {
"jwtSecret": "dev-secret",
"appUrl": "http://localhost:5173/app"
},
"server": {
"allowedDomains": ["*"]
},
"phaset": {
"demoMode": true,
"bootstrap": {
"organizationName": "Dev Org",
"adminEmail": "[email protected]"
}
}
}

Goal: Secure production deployment on your infrastructure

{
"email": {
"user": "[email protected]",
"password": "secure-app-password",
"host": "smtp.gmail.com",
"port": 465,
"secure": true
},
"auth": {
"jwtSecret": "generated-with-openssl-rand-base64-32",
"appUrl": "https://phaset.yourcompany.com/app",
"jwtExpirySeconds": 3600,
"refreshTokenExpirySeconds": 2592000
},
"server": {
"allowedDomains": [
"https://phaset.yourcompany.com"
]
},
"phaset": {
"licenseKey": "your-license-key-if-applicable",
"bootstrap": {
"organizationName": "Your Company",
"adminEmail": "[email protected]"
}
}
}

Cloud Platform (Using Environment Variables)

Section titled “Cloud Platform (Using Environment Variables)”

Goal: Deploy on DigitalOcean, AWS, or similar without managing config files

Set these environment variables in your platform’s dashboard:

Terminal window
# Required
EMAIL_HOST=smtp.sendgrid.net
EMAIL_USER=apikey
EMAIL_PASSWORD=your-sendgrid-api-key
BOOTSTRAP_ORG_NAME="Your Company"
BOOTSTRAP_ADMIN_EMAIL=[email protected]
# Important
AUTH_JWT_SECRET=your-secure-random-string
APP_URL=https://phaset.yourcompany.com/app
ALLOWED_DOMAINS=https://phaset.yourcompany.com
# Optional
EMAIL_PORT=465
EMAIL_SECURE=true
PORT=3000

Always generate a strong, random JWT secret:

Terminal window
openssl rand -base64 32

Never commit secrets to version control. Use environment variables or secret management tools.

If you provide a storage.encryptionKey, Phaset encrypts sensitive data at rest. Generate it the same way:

Terminal window
openssl rand -base64 32

In production, never use "allowedDomains": ["*"]. Always specify exact domains:

"allowedDomains": [
"https://phaset.yourcompany.com"
]