selfhost.directory

The index of self-hostable projects — ranked, categorized and served with live updates.
Own your data and stop giving it to big tech.

sama-server logo

Self-host sama-server

0.37.2

Open-source chat server with clustering

BetaOpen SourceGPL-3.0
Updated11 hours ago
LanguageJavaScript
Setup difficultyAdvanced
MobileResponsive
Stars
161
Ports
9001 (WebSocket API), 8001 (TCP)
Requires
MinIO (S3-compatible storage), MongoDB, Redis
Install with Docker Compose
SAMA chat server UI screenshot

What is sama-server?

SAMA is a self-hosted chat server built as an alternative to XMPP. It delivers real-time messaging with rich media, private and group chats, typing and read receipts, and file sharing. Users can stay connected across multiple devices with flexible online/offline message delivery. Push notifications work via APNS, FCM, and Web Push. The server clusters horizontally using Redis for coordination, with MongoDB for data and MinIO for file storage. Deployment options include Docker Compose (single-command or local development) and manual Node.js 22 setup. A free GPL-3.0 edition is available alongside a commercial Enterprise tier with dedicated support and an XMPP bridge add-on.

Should you self-host sama-server?

sama-server scores 45/100 on selfhost.directory (how scoring works) and ranks #68 of 110 in Chat. It has 161 GitHub stars.

It shipped 5 stable releases in the past year. The latest, 0.37.2, came out on 10 September 2026. New versions land roughly every 2 months.

Setup is advanced: plan for several services and some ongoing maintenance. It is GPL-3.0-licensed and written mostly in JavaScript.

Its closest alternative on selfhost.directory is Tinode (67/100, 13 540 stars). It scores higher overall, so compare the two before you pick. See sama-server vs Tinode side by side.

Features

  • Admin Dashboard
  • End-to-end encryption
  • Extensive WebSocket API
  • File attachments
  • HTTP Admin API
  • Message History API
  • Message Status Indicators
  • Multi-device Support
  • Private and Group Chats
  • Programmable Chat
  • Push Notifications
  • Real-time Messaging
  • Server Clustering
  • User Management
  • XMPP BridgeOnly available in commercial Enterprise edition

sama-server README

How to install sama-server

Install sama-server with Docker Compose

Docker and Docker Compose

docker-compose -f docker-compose-full.yml up --build

One-command deployment with all dependencies

How to configure sama-server

  • APP_PORT9001
  • APP_REPL_FILE_IN/tmp/pipe-repl.infile

    file

  • APP_REPL_FILE_OUT/tmp/pipe-repl.out
  • APP_REPL_HTTP_ACCESS_KEY
  • APP_REPL_HTTP_PORT5010REPL http

    REPL http

  • APP_REPL_SOCKET_HANDLER/tmp/net-repl.socketsocket

    socket

  • APP_TCP_PORT8001
  • CHAT_BOT_LOGINserver-chat-bot
  • CHAT_BOT_PASSWORD
  • CONVERSATION_DISABLE_CHANNELS_LOGICfalse
  • CONVERSATION_MAX_PARTICIPANTS50
  • CONVERSATION_NOTIFICATIONS_ENABLEDtrue
  • CONVERSATION_PRELOAD_COUNT30
  • COOKIE_SECRET
  • CORS_ORIGINhttp://localhost:3000
  • ENCRYPTION_DEVICE_TOKEN_EXPIRES_IN
  • ENCRYPTION_MESSAGE_EXPIRED_IN2592000
  • FILE_DOWNLOAD_URL_EXPIRES_IN604800
  • FILE_UPLOAD_URL_EXPIRES_IN3600
  • GOOGLE_GENERATIVE_AI_API_KEY
  • GOOGLE_GENERATIVE_AI_MODELgemini-2.5-flash
  • HOSTNAMENodeNameset this env if you want to override the os.hostname() value

    set this env if you want to override the os.hostname() value

  • HTTP_ADMIN_API_KEY
  • JWT_ACCESS_SECRETtoken
  • JWT_ACCESS_TOKEN_EXPIRES_IN
  • JWT_REFRESH_SECRETrefresh
  • JWT_REFRESH_TOKEN_EXPIRES_IN
  • LOG_LEVELdebug
  • LOG_SINGLE_LINEfalse
  • MESSAGE_PRELOAD_COUNT30
  • MINIO_ACCESS_KEY
  • MINIO_BUCKET_NAMEsamabucket
  • MINIO_ENDPOINT127.0.0.1
  • MINIO_PORT9010
  • MINIO_ROOT_PASSWORD
  • MINIO_ROOT_USERe7walulcatDu7waekVSkIf you set STORAGE_DRIVER=minio, then fill the below envs

    If you set STORAGE_DRIVER=minio, then fill the below envs

  • MINIO_SECRET_KEY
  • MINIO_USE_SSLfalse
  • MONGODB_URLmongodb://127.0.0.1/samadb
  • NODE_1_HTTP_ENDPOINThttp://localhost:9001
  • NODE_1_WS_ENDPOINTws://localhost:9001
  • NODE_2_HTTP_ENDPOINThttp://localhost:9002
  • NODE_2_WS_ENDPOINTws://localhost:9002
  • NODE_CLUSTER_DATA_EXPIRES_IN30000
  • NODE_ENVdevelopment
  • OPERATIONS_LOG_EXPIRES_IN1209600
  • REDIS_SUB_DATA_EXPIRES_IN30000
  • REDIS_URLredis://127.0.0.1:6379
  • RESEND_API_KEY
  • RESEND_SENDER
  • RUN_NODE_1_CMDAPP_PORT=9001 APP_TCP_PORT=8001 CORS_ORIGIN=http://localhost:3001 npm startTesting

    Testing

  • RUN_NODE_2_CMDAPP_PORT=9002 APP_TCP_PORT=8002 CORS_ORIGIN=http://localhost:3002 npm start
  • S3_ACCESS_KEYIf you set STORAGE_DRIVER=s3, then fill the below envs

    If you set STORAGE_DRIVER=s3, then fill the below envs

  • S3_BUCKET_NAMEsamabucket
  • S3_ENDPOINT
  • S3_REGIONus-east-1
  • S3_SECRET_KEY
  • SAMA_NATIVE_PUSH_QUEUE_NAMEpush_notifications
  • SEARCH_PRELOAD_COUNT30
  • SERVICE_OTP_TOKEN_EXPIRES_IN
  • SPACES_ACCESS_KEYIf you set STORAGE_DRIVER=spaces, then fill the below envs

    If you set STORAGE_DRIVER=spaces, then fill the below envs

  • SPACES_BUCKET_NAMEsamabucket
  • SPACES_ENDPOINT127.0.0.1
  • SPACES_REGIONus-east-1
  • SPACES_SECRET_KEY
  • SSL_CERT_FILE_NAME
  • SSL_KEY_FILE_NAME
  • STANDALONE_NODEfalse
  • STORAGE_DRIVERminio
  • TEST_CLIENT_HTTP_ENDPOINThttp://localhost:9001
  • TEST_CLIENT_ORG_ID683db99d3874471b4dd36c69
  • TEST_CLIENTS_COUNT10
  • TEST_CLIENT_WS_ENDPOINTws://localhost:9001
  • TLS_CERT_FILE_NAME
  • TLS_KEY_FILE_NAME
  • WATCHDOG_PING_SOCKET_INTERVAL60000

sama-server releases & version history

More in Messaging

Rate this project

Click to rate — no account needed.

0 comments

Posting as guest
Loading comments…