Configuration
Configuration Guide
Learn how to configure sms-dev using CLI arguments, configuration files, and environment variables.
Configuration Precedence
sms-dev loads configuration from multiple sources with the following precedence (highest to lowest):
CLI Arguments
Flags passed directly to commands
sms-dev start --api-port 4002
Configuration Files
JavaScript or JSON config files
sms-dev.config.js
Environment Variables
System environment variables
SMS_DEV_API_PORT=4002
Default Values
Built-in defaults when no other configuration is found
apiPort: 4001, uiPort: 4000
Configuration Resolution
Higher precedence values override lower ones. For example, --api-port 4002
will override both environment variables and config file settings.
Quick Start
The fastest way to get started is with CLI arguments for simple configurations:
Basic Usage
sms-dev start
Starts with defaults: API on port 4001, UI on port 4000
Custom Ports
sms-dev start --api-port 5001 --ui-port 5000
Use custom ports for both API and UI servers
With Webhook URL
sms-dev start --webhook-url http://localhost:3000/webhook/sms
Forward SMS replies to your application's webhook endpoint
CLI Arguments
CLI arguments have the highest precedence and override all other configuration sources.
Available Arguments
--config
-c
stringConfiguration file path--api-port
-p
numberAPI server port--ui-port
-u
numberUI server port--webhook-url
-
stringWebhook URL for testing--no-ui
-
booleanStart only API server--verbose
-
booleanEnable verbose logging--show-config
-
booleanShow config and exitConfiguration Files
Configuration files provide a persistent way to configure sms-dev. Multiple file formats are supported.
File Discovery Order
sms-dev looks for configuration files in this order:
- 1
sms-dev.config.js
- 2
sms-dev.config.json
- 3
.smsdevrc
(JSON format)
JavaScript Configuration
Most flexible option with full JavaScript support:
// sms-dev.config.js
module.exports = {
// Server configuration
apiPort: 4001,
uiPort: 4000,
// Start UI server
startUI: true,
// Webhook configuration
webhookUrl: 'http://localhost:3000/webhook/sms',
// CORS configuration
cors: {
enabled: true,
origins: ['http://localhost:3000', 'http://localhost:3001']
},
// Logging configuration
logging: {
enabled: true,
level: 'info' // 'debug' | 'info' | 'warn' | 'error'
},
// Development mode
verbose: false
}
JSON Configuration
Simple JSON format for basic configurations:
{
"apiPort": 4001,
"uiPort": 4000,
"startUI": true,
"webhookUrl": "http://localhost:3000/webhook/sms",
"cors": {
"enabled": true,
"origins": ["*"]
},
"logging": {
"enabled": true,
"level": "info"
},
"verbose": false
}
Generate Configuration
Use the init command to generate a sample configuration:
sms-dev init
Creates sms-dev.config.js
sms-dev init --json
Creates sms-dev.config.json
Environment Variables
Environment variables provide system-level configuration and are useful for deployment environments.
Available Variables
SMS_DEV_API_PORT
numberAPI server portSMS_DEV_UI_PORT
numberUI server portSMS_DEV_WEBHOOK_URL
stringWebhook URLSMS_DEV_NO_UI
booleanDisable UI serverSMS_DEV_VERBOSE
booleanEnable verbose loggingUsage Examples
Set environment variables:
export SMS_DEV_API_PORT=5001
export SMS_DEV_UI_PORT=5000
export SMS_DEV_WEBHOOK_URL=http://localhost:3000/webhook
sms-dev start
Inline environment variables:
SMS_DEV_VERBOSE=true sms-dev start --no-ui
Configuration Options Reference
Server Options
apiPort
numberdefault: 4001Port for the API server that handles SMS message requests.
uiPort
numberdefault: 4000Port for the Virtual Phone UI web interface.
startUI
booleandefault: trueWhether to start the Virtual Phone UI server alongside the API server.
Webhook Options
webhookUrl
stringoptionalURL to forward inbound SMS messages to your application for webhook testing.
Logging Options
verbose
booleandefault: falseEnable verbose logging for debugging and development.
logging.enabled
booleandefault: trueWhether to enable logging output.
logging.level
stringdefault: "info"Logging level: "debug", "info", "warn", or "error".
Debugging Configuration
Use these commands to debug configuration issues:
Show Current Configuration
sms-dev config
Displays the resolved configuration from all sources
Show Configuration and Exit
sms-dev start --show-config
Shows what configuration would be used without starting servers
Use Specific Config File
sms-dev start --config /path/to/custom.config.js
Load configuration from a specific file path