Deploying TalkBox requires running two separate services: a persistent Node.js process for the Express and Socket.IO server, and a static site host for the compiled React client. Because Socket.IO relies on long-lived WebSocket connections, the server must run on a platform that supports persistent TCP connections — not a serverless runtime. Follow the steps below to go from a local development checkout to a working production deployment.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/abdelhafid37/talkbox/llms.txt
Use this file to discover all available pages before exploring further.
Provision a MongoDB database
Create a MongoDB database that your server can reach over the public internet.
- MongoDB Atlas (recommended): Create a free-tier cluster at cloud.mongodb.com, create a database user, and whitelist your server’s IP address (or
0.0.0.0/0during initial setup). Copy the connection string from the Atlas dashboard — it will look likemongodb+srv://<username>:<password>@<cluster>.mongodb.net/<dbname>?retryWrites=true&w=majority. - Self-hosted: Ensure your MongoDB instance is reachable from the server host and note the full URI.
MONGO_URI value ready for the next step.Deploy the server
Upload or clone the
Start the server with Confirm the server is running by visiting
server/ directory to your hosting platform (Railway, Render, a VPS, etc.), then set the following environment variables in your host’s dashboard or via a secrets manager — do not ship a .env file in your deployment artefact:| Variable | Production value |
|---|---|
PORT | Port assigned by your platform, e.g. 8080 |
MONGO_URI | Your Atlas or self-hosted connection string |
JWT_SECRET | A strong random secret (≥ 32 chars) |
CLIENT_URL | Your production frontend URL (set after Step 3) |
npm start, which runs node src/server.js directly. Do not use npm run dev in production — the dev script uses nodemon, which watches the filesystem for changes and restarts the process automatically. That behaviour wastes resources and can cause instability under production load. npm start launches Node without any watcher.https://<your-server-host>/ — you should see the plain text response TalkBox API Running.Build and deploy the client
In the Vite compiles the React app and writes optimised static assets to
client/ directory, set VITE_API_URL to the public URL of the server you deployed in Step 2, then run the Vite build:client/dist/. Deploy that folder to a static host:- Vercel / Netlify: Connect the repository and set the build command to
npm run build, the output directory todist, and theVITE_API_URLenvironment variable in the project settings. - Nginx: Copy the
dist/contents to your web root and add atry_files $uri /index.html;directive so that client-side routing works correctly.
Set CORS to match the production frontend URL
The A mismatch here will cause all API requests and WebSocket connections from the browser to be blocked by the browser’s same-origin policy. Restart the server after changing this value.
CLIENT_URL environment variable on the server is passed verbatim to both Express CORS middleware and Socket.IO’s CORS configuration. It must match the exact origin of your deployed frontend — including the protocol (https://) and without a trailing slash.For example, if your frontend is served at https://talkbox.example.com, set:Verify the deployment
Open your production frontend URL in a browser and confirm end-to-end functionality:
- Register a new user account.
- Log in and observe that the user list loads (confirming REST API connectivity).
- Open a second browser window or incognito tab, register another user, and send a message between the two accounts.
- Confirm that the message appears in real time without a page refresh (confirming WebSocket connectivity).
CLIENT_URL and VITE_API_URL are consistent with the deployed URLs.Production environment variables reference
The table below summarises every variable required for a production deployment across both services.| Service | Variable | Example production value | Purpose |
|---|---|---|---|
| Server | PORT | 8080 | Port the Express server binds to |
| Server | MONGO_URI | mongodb+srv://user:pass@cluster.mongodb.net/talkbox | MongoDB connection string |
| Server | JWT_SECRET | (strong random string) | Signs and verifies JWTs |
| Server | CLIENT_URL | https://talkbox.example.com | Allowed CORS origin for REST and WebSocket |
| Client | VITE_API_URL | https://api.talkbox.example.com | Base URL for Axios and Socket.IO client |
TalkBox uses Socket.IO for real-time messaging, which requires a persistent WebSocket connection. Serverless platforms (AWS Lambda, Vercel Edge Functions, Cloudflare Workers) do not support long-lived TCP connections and will not work for the server component. Use a platform that runs a continuous Node.js process — Railway, Render (Web Service tier), or a traditional VPS (e.g. DigitalOcean Droplet, Hetzner) are all suitable choices.