Skip to content

CLI and Server Options

The mikrochat CLI is installed via the curl oneliner and provides commands for managing your MikroChat installation.

Terminal window
curl -sSL https://releases.mikrochat.com/install.sh | bash
CommandDescription
mikrochat installDownload and install MikroChat to ~/.mikrochat/
mikrochat initCreate config and copy web app to current directory
mikrochat startStart the MikroChat API server
mikrochat upgradeCheck for updates and upgrade to the latest version
mikrochat versionShow the installed version
mikrochat uninstallRemove MikroChat from your system
mikrochat docsOpen the documentation in your browser
  • ~/.mikrochat/ stores the installed API and web app files
  • ~/.local/bin/mikrochat is the CLI wrapper script
  • mikrochat start runs the API from your current working directory, so mikrochat.config.json and mikrochat_db/ live in your project folder
  • mikrochat init copies the web app files to ./app/ in your current directory for easy web server setup

Any flags after mikrochat start are forwarded to the Node.js server:

Terminal window
mikrochat start --port 4000 --debug

MikroChat can also be started directly with Node.js. All configuration can be provided via CLI flags, environment variables, or a configuration file.

Terminal window
# Using the CLI
mikrochat start
# Using Node.js directly
node mikrochat.mjs
# With options
node mikrochat.mjs --port 3001 --debug
FlagDescriptionDefault
--portPort to listen on3000
--hostHost/bind addresslocalhost
--httpsEnable HTTPSfalse
--http2Enable HTTP/2false
--certSSL certificate path-
--keySSL private key path-
--caSSL CA certificate path-
--ratelimitEnable rate limitingtrue
--rpsRequests per minute limit100
--allowedComma-separated allowed domains-
--debugEnable debug modefalse
FlagDescriptionDefault
--jwtSecretJWT signing key-
--appUrlBase URL for magic links-
--magicLinkExpirySecondsMagic link expiry time900
--jwtExpirySecondsJWT expiry time900
--refreshTokenExpirySecondsRefresh token expiry604800
--maxActiveSessionsMax sessions per user3
--authModeAuth modemagic-link
--isInviteRequiredRequire admin invitetrue
FlagDescriptionDefault
--initialUserIdInitial admin user ID-
--initialUserNameInitial admin username-
--initialUserEmailInitial admin email-
--initialUserPasswordInitial admin password-
--messageRetentionDaysDays to keep messages30
--maxMessagesPerChannelMax messages per channel100
FlagDescriptionDefault
--emailSubjectMagic link email subjectYour Secure Login Link
--emailHostSMTP host-
--emailUserSMTP username-
--emailPasswordSMTP password-
--emailPortSMTP port465
--emailSecureUse secure connectiontrue
--emailMaxRetriesMax delivery attempts2
FlagDescriptionDefault
--dbDatabase directory pathmikrochat_db
--encryptionKeyEncryption key for data at rest-
VariableDescription
PORTServer port
HOSTServer host
DEBUGEnable debug mode
AUTH_JWT_SECRETJWT signing key
APP_URLBase URL for magic links
INITIAL_USER_IDInitial admin user ID
INITIAL_USER_NAMEInitial admin username
INITIAL_USER_EMAILInitial admin email
INITIAL_USER_PASSWORDInitial admin password
EMAIL_USERSMTP username
EMAIL_HOSTSMTP host
EMAIL_PASSWORDSMTP password
STORAGE_KEYEncryption key

Create mikrochat.config.json in the working directory:

{
"auth": {
"jwtSecret": "your-secret-key",
"authMode": "magic-link",
"appUrl": "https://chat.example.com",
"isInviteRequired": true
},
"chat": {
"initialUser": {
"userName": "admin",
"email": "admin@example.com",
"password": ""
}
},
"server": {
"port": 3000
}
}

See Configuration for the complete reference.

Settings are applied in this order (highest priority first):

  1. CLI flags
  2. Configuration file (mikrochat.config.json)
  3. Default values (which include environment variables)
Terminal window
# Start with dev mode (from source)
npm start
# Custom port
mikrochat start --port 3001 --debug
Terminal window
# With environment variables
PORT=3000 \
AUTH_JWT_SECRET=your-secret \
EMAIL_HOST=smtp.example.com \
EMAIL_USER=noreply@example.com \
EMAIL_PASSWORD=password \
mikrochat start
# With HTTPS
mikrochat start \
--https \
--cert /path/to/cert.pem \
--key /path/to/key.pem
# With rate limiting
mikrochat start --ratelimit --rps 60
Terminal window
docker run -d \
-e PORT=3000 \
-e AUTH_JWT_SECRET=your-secret \
-v mikrochat-data:/app/mikrochat_db \
-p 3000:3000 \
mikrochat

When working with the source code:

ScriptDescription
npm run devStart frontend file server (port 8000)
npm run dev:reloadBuild frontend + start backend (port 3000)
npm startStart the backend server
npm run buildBuild everything for production
npm run build:webBuild frontend only
npm run build:apiBuild backend only
npm testRun tests
npm run lintRun linter

Enable debug mode to see verbose logs:

Terminal window
# Via CLI flag
mikrochat start --debug
# Via environment variable
DEBUG=true mikrochat start

Debug mode logs:

  • Incoming HTTP requests
  • Authentication events
  • Database operations
  • SSE connection lifecycle
  • Email delivery attempts

The server exposes a health endpoint:

Terminal window
curl http://localhost:3000/health
# Returns: OK

Use this for container health checks and load balancer probes.