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 4002Configuration Files
JavaScript or JSON config files
sms-dev.config.jsEnvironment Variables
System environment variables
SMS_DEV_API_PORT=4002Default Values
Built-in defaults when no other configuration is found
apiPort: 4001, uiPort: 4000Configuration 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 startStarts with defaults: API on port 4001, UI on port 4000
Custom Ports
sms-dev start --api-port 5001 --ui-port 5000Use custom ports for both API and UI servers
With Webhook URL
sms-dev start --webhook-url http://localhost:3000/webhook/smsForward 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-cstringConfiguration file path--api-port-pnumberAPI server port--ui-port-unumberUI 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 initCreates sms-dev.config.js
sms-dev init --jsonCreates sms-dev.config.json
Environment Variables
Environment variables provide system-level configuration and are useful for deployment environments.
Available Variables
SMS_DEV_API_PORTnumberAPI server portSMS_DEV_UI_PORTnumberUI server portSMS_DEV_WEBHOOK_URLstringWebhook URLSMS_DEV_NO_UIbooleanDisable UI serverSMS_DEV_VERBOSEbooleanEnable 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 startInline environment variables:
SMS_DEV_VERBOSE=true sms-dev start --no-uiConfiguration Options Reference
Server Options
apiPortnumberdefault: 4001Port for the API server that handles SMS message requests.
uiPortnumberdefault: 4000Port for the Virtual Phone UI web interface.
startUIbooleandefault: trueWhether to start the Virtual Phone UI server alongside the API server.
Webhook Options
webhookUrlstringoptionalURL to forward inbound SMS messages to your application for webhook testing.
Logging Options
verbosebooleandefault: falseEnable verbose logging for debugging and development.
logging.enabledbooleandefault: trueWhether to enable logging output.
logging.levelstringdefault: "info"Logging level: "debug", "info", "warn", or "error".
Debugging Configuration
Use these commands to debug configuration issues:
Show Current Configuration
sms-dev configDisplays the resolved configuration from all sources
Show Configuration and Exit
sms-dev start --show-configShows what configuration would be used without starting servers
Use Specific Config File
sms-dev start --config /path/to/custom.config.jsLoad configuration from a specific file path