Welcome to Commex, the modern, self-hosted embeddable commenting platform where you own your data. This guide covers everything you need to get up and running—from local development to production deployment.
Firstly You can just create an Account in https://commex.anipub.xyz and create a org there ... get the embed code code and paste it whereever you want in your website
- What is Commex?
- How Commex Compares
- System Requirements
- Quick Start
- MongoDB Setup
- Environment Configuration
- Development
- Creating Your First Organization
- Embedding on Your Website
- Production Deployment
- Troubleshooting
- Contributing
Commex is a Disqus alternative that gives you complete control over your data. Unlike traditional commenting platforms, each organization stores its data in its own MongoDB database, ensuring:
- You own your data — no third-party lock-in
- Privacy-first — comments never leave your infrastructure
- Self-hosted — deploy on your own server or cloud
- Easy embed — just 2 lines of code on your website
- Threaded Comments — nested replies with unlimited depth
- Reactions — 10+ emoji reactions + upvote/downvote
- GIF Picker — Tenor integration (or GIPHY)
- Image Support — URL-based attachments
- Mentions — notify users automatically
- Moderation — pin comments, flag spam, word filtering
- Edit & Delete — preserve thread structure with soft-delete
- Domain Allowlist — restrict embeds to your domains
- Custom Branding — per-org accent colors
- Notifications — reply & mention alerts
- Dashboard — manage all settings from one place
- Responsive Design — works on all devices
| Feature | Commex | Disqus | Giscus | Utterances | Commento |
|---|---|---|---|---|---|
| Self-Hosted | Yes | No | Yes | No | Yes |
| Own Your Data | Yes | No | Yes | No | Yes |
| Cost | Free (self-hosted) | $0-499/mo | Free | Free | Free/$5-10mo |
| Database Type | MongoDB (per-org) | Proprietary | GitHub Issues | GitHub Issues | SQLite/PostgreSQL |
| Threaded Comments | Yes | Yes | No | No | Yes |
| Reactions/Emoji | Yes (10+) | Yes | Yes (GitHub only) | Yes (GitHub only) | Limited |
| GIF Support | Yes | Yes | No | No | No |
| Image Support | Yes | Yes | No | No | No |
| @Mentions | Yes | Yes | Yes | No | Yes |
| Moderation Tools | Yes | Yes | Limited | No | Yes |
| Mobile Responsive | Yes | Yes | Yes | Yes | Yes |
| Authentication | Username/Email | Social/Email | GitHub | GitHub | Email/OAUTH |
| Dark Mode | Yes | Limited | Yes | Yes | Yes |
| GDPR Compliant | Yes | No | Yes | Yes | Yes |
| Learning Curve | Medium | Easy | Easy | Easy | Medium |
| Performance | Excellent | Good | Excellent | Excellent | Good |
| Community Support | Growing | Large | Large | Growing | Small |
- Data Ownership: Your comments stay in your database—no vendor lock-in
- Flexibility: Each organization controls its own MongoDB instance
- Privacy: GDPR compliant with full data control
- Modern UX: Dark-first, responsive design with threading
- Rich Media: GIFs, images, and emoji reactions out of the box
- Scalable: Self-hosted means unlimited scale based on your infrastructure
- Node.js 18+
- npm 8+ or yarn 3+
- MongoDB 4.4+ (Atlas or self-hosted)
- Git
git clone https://github.com/OpenCommex/Commex.git
cd Commex
npm installChoose one:
- MongoDB Atlas (Cloud) — Easiest, no setup required
- Self-Hosted MongoDB — Full control
cp .env.example .envEdit .env with your MongoDB connection string:
PORT=3000
MONGODB_URI=mongodb+srv://user:password@cluster.mongodb.net/commex
JWT_SECRET=your-long-random-secret-here
APP_URL=http://localhost:3000
TENOR_API_KEY=your-tenor-api-key # optionalnpm run devVisit http://localhost:3000 — you're live!
Commex uses two MongoDB databases:
- Central DB — stores users and organization metadata (set in MONGODB_URI)
- Per-org DB — each organization provides its own connection string for storing comments/reactions
Choose the setup that best fits your needs:
Recommended for: First-time users, small to medium projects, minimal DevOps.
- Go to https://www.mongodb.com/cloud/atlas
- Click Sign Up and create your account
- Verify your email
- Click New Project in the left sidebar
- Enter a project name (e.g., "Commex")
- Click Next → Create Project
- In your project, click Build a Cluster
- Select the Free tier (M0) for testing, or M2/M5+ for production
- Choose your cloud provider (AWS, Google Cloud, or Azure) and region closest to your users
- Click Create Cluster (takes 2-3 minutes)
- Go to Database Access in the left sidebar
- Click Add New Database User
- Choose Password Authentication
- Enter username:
commex_user - Enter password: (generate a strong one or use the auto-generated option)
- Limit to specific databases (optional, recommended)
- Click Add User
Keep your password safe!
IMPORTANT: To allow connections from anywhere (development/testing), you must whitelist 0.0.0.0:
-
Go to Network Access in the left sidebar
-
Click Add IP Address
-
Enter
0.0.0.0/0to allow all IPs (Development only!)For Production: Use your actual server IP address instead of 0.0.0.0
-
Click Confirm
SECURITY NOTE: 0.0.0.0/0 allows anyone to connect if they have your credentials. For production, replace with your server's IP or use other authentication methods (VPC, IP ranges, etc.).
-
Go back to Clusters
-
Click Connect on your cluster
-
Select Drivers
-
Choose Node.js and version 5.5 or later
-
Copy the connection string:
mongodb+srv://commex_user:YOUR_PASSWORD@cluster.mongodb.net/commex -
Replace YOUR_PASSWORD with your actual password
- Click Browse Collections in your cluster
- Click + Create Database
- Create the main database:
- Database name:
commex - Collection name:
users - Click Create
- Database name:
Now add the connection string to your .env:
MONGODB_URI=mongodb+srv://commex_user:YOUR_PASSWORD@cluster.mongodb.net/commexRecommended for: Full control, large deployments, on-premises environments.
On Ubuntu/Debian:
# Add MongoDB GPG key
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/mongodb-server-7.0.gpg
# Add MongoDB repository
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
# Update and install
sudo apt-get update
sudo apt-get install -y mongodb-orgOn macOS (with Homebrew):
brew tap mongodb/brew
brew install mongodb-communityOn Windows:
Download and run the MongoDB installer at https://www.mongodb.com/try/download/community
On Linux (systemd):
sudo systemctl start mongod
sudo systemctl enable mongod # Auto-start on rebootOn macOS (Homebrew):
brew services start mongodb-communityOn Windows (PowerShell as Administrator):
net start MongoDBmongo --eval "db.version()"You should see the version number (e.g., 7.0.0).
Open the MongoDB shell:
mongosh # MongoDB 5.0+
# OR
mongo # MongoDB <5.0Run these commands:
// Switch to admin database
use admin
// Create admin user (if needed)
db.createUser({
user: "admin",
pwd: "admin_password",
roles: ["root"]
})
// Switch to your commex database
use commex
// Create commex user
db.createUser({
user: "commex_user",
pwd: "commex_password",
roles: [
{ role: "readWrite", db: "commex" }
]
})
// Verify user was created
show usersExit the shell:
exitEdit MongoDB configuration file:
On Linux:
sudo nano /etc/mongod.confOn macOS:
nano /usr/local/etc/mongod.confFind the net: section and update:
net:
port: 27017
bindIp: 0.0.0.0 # Allow connections from any IP
# For production, use specific IPs: bindIp: 127.0.0.1,10.0.0.5Restart MongoDB:
sudo systemctl restart mongod # Linux
brew services restart mongodb-community # macOSEdit MongoDB config:
security:
authorization: enabledRestart MongoDB and reconnect:
mongosh -u admin -p admin_password --authenticationDatabase adminLocal Development:
mongodb://commex_user:commex_password@localhost:27017/commex
Remote Connection (from another server):
mongodb://commex_user:commex_password@YOUR_SERVER_IP:27017/commex
With Authentication:
mongodb://commex_user:commex_password@localhost:27017/commex?authSource=admin
Add to .env:
MONGODB_URI=mongodb://commex_user:commex_password@localhost:27017/commex?authSource=adminmongosh -u commex_user -p commex_password --authenticationDatabase admin
use commex
db.createCollection("users")Create a .env file in the root directory:
# Server
PORT=3000
NODE_ENV=development
# Database (Main)
MONGODB_URI=mongodb+srv://commex_user:YOUR_PASSWORD@cluster.mongodb.net/commex
# Security
JWT_SECRET=your-long-random-secret-here-change-this-in-production
JWT_EXPIRES_IN=7d
# Application
APP_URL=http://localhost:3000
# Optional: GIF Search
TENOR_API_KEY=your-tenor-api-key
# Optional: Rate Limiting
RATE_LIMIT_WINDOW_MS=900000 # 15 minutes
RATE_LIMIT_MAX=100 # 100 requests per windowopenssl rand -base64 32Copy the output and paste it as JWT_SECRET.
npm run devThe server will auto-reload on file changes. Visit http://localhost:3000
npm run buildnpm start-
Register an account at http://localhost:3000
-
Click Dashboard
-
Click Create Organization
-
Fill in:
- Organization Name (e.g., "My Blog")
- MongoDB Connection String — this is where comments will be stored
Examples:
- Atlas:
mongodb+srv://user:pass@cluster.mongodb.net/my-blog - Self-hosted:
mongodb://user:pass@localhost:27017/my-blog?authSource=admin
-
Click Test Connection to verify
-
Click Create
-
Go to Embed tab and copy your snippet
Add this to any HTML page where you want comments:
<!-- Commex Comments Widget -->
<div id="commex-widget"></div>
<script>
window.CommexConfig = {
orgSlug: "my-blog", // Your organization slug
pageUrl: window.location.href, // Current page URL
pageTitle: document.title, // Current page title
};
</script>
<script src="https://your-commex-domain.com/embed/commex.js" async></script>| Option | Required | Default | Description |
|---|---|---|---|
| orgSlug | Yes | — | Your organization slug (from dashboard) |
| pageUrl | No | window.location.href | Unique identifier for this page's comments |
| pageTitle | No | document.title | Page title shown in notifications |
| targetId | No | commex-widget | HTML element ID to mount widget |
| theme | No | dark | dark or light |
| accentColor | No | — | Custom accent color (hex, e.g., #7c3aed) |
<article>
<h1>My First Blog Post</h1>
<p>Article content here...</p>
<!-- Comments Section -->
<section style="margin-top: 2rem;">
<h2>Comments</h2>
<div id="commex-widget"></div>
<script>
window.CommexConfig = {
orgSlug: "my-blog",
pageUrl: "https://example.com/blog/first-post",
pageTitle: "My First Blog Post",
theme: "dark"
};
</script>
<script src="https://your-commex-domain.com/embed/commex.js" async></script>
</section>
</article>Create a Dockerfile (already in repo):
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD ["node", "src/server.js"]Build and run:
docker build -t commex .
docker run -p 3000:80 \
-e MONGODB_URI="mongodb+srv://user:pass@..." \
-e JWT_SECRET="your-secret" \
-e APP_URL="https://commex.example.com" \
commex- SSH into your server
- Clone the repo:
git clone https://github.com/OpenCommex/Commex.git
cd Commex
npm install- Create
.envwith production values:
NODE_ENV=production
PORT=3000
MONGODB_URI=mongodb+srv://user:pass@cluster.mongodb.net/commex
JWT_SECRET=$(openssl rand -base64 32)
APP_URL=https://commex.example.com- Install and start with PM2:
npm install -g pm2
pm2 start src/server.js --name commex
pm2 save
pm2 startup- Set up Nginx reverse proxy:
server {
listen 80;
server_name commex.example.com;
# Redirect HTTP to HTTPS
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name commex.example.com;
ssl_certificate /etc/letsencrypt/live/commex.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/commex.example.com/privkey.pem;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
}- Enable SSL with Let's Encrypt:
sudo apt install certbot python3-certbot-nginx
sudo certbot certonly --nginx -d commex.example.comError: MongoNetworkError: getaddrinfo ENOTFOUND cluster.mongodb.net
Solution:
- Check your MONGODB_URI is correct
- Verify IP 0.0.0.0 is whitelisted in MongoDB Atlas
- Ensure your network allows outbound connections on port 27017
# Find and kill the process
lsof -i :3000
kill -9 <PID>
# Or use a different port
PORT=3001 npm run devError: JWT_SECRET is required
Solution:
# Generate one
openssl rand -base64 32
# Add to .env
echo "JWT_SECRET=$(openssl rand -base64 32)" >> .envError: MongoAuthenticationError: authentication failed
Solution:
- Double-check username and password in MONGODB_URI
- For self-hosted: verify authSource=admin is in the connection string
- Reset MongoDB user credentials:
use admin
db.dropUser("commex_user")
db.createUser({
user: "commex_user",
pwd: "new_password",
roles: [{ role: "readWrite", db: "commex" }]
})- Check console for errors (F12)
- Verify orgSlug matches your dashboard slug
- Ensure CORS is allowed (should be by default)
- Check that APP_URL matches your domain in production
We love contributions! Here's how:
- Fork the repository
- Create a feature branch:
git checkout -b feature/awesome-feature - Commit your changes:
git commit -m 'Add awesome feature' - Push to the branch:
git push origin feature/awesome-feature - Open a Pull Request
git clone https://github.com/OpenCommex/Commex.git
cd Commex
npm install
npm run dev- Use 2-space indentation
- Follow ESLint rules:
npm run lint - Write meaningful commit messages
GPL3 License — See LICENSE file for details.
- Issues: https://github.com/OpenCommex/Commex/issues
- Discussions: https://github.com/OpenCommex/Commex/discussions
- Email: abdullahaladnan95@gmail.com (maintainer)
- Frontend: HTML, JavaScript, CSS (Dark-first design)
- Backend: Node.js 18+
- Database: MongoDB 4.4+
- Deployment: Docker, PM2, or VPS
- GIF Provider: Tenor API
Made with care by the OpenCommex team. Happy commenting!