Deploy Your Express.js API to Production
Express.js remains the most widely used Node.js web framework in 2026. Its minimal surface area and massive ecosystem make it the default choice for REST APIs, GraphQL servers, and lightweight backends. Getting it running locally takes minutes — but moving to production can still trip developers up with Dockerfiles, reverse proxies, and environment management.
PandaStack removes that friction. Connect your GitHub repository, and PandaStack runs your container in a managed cloud environment. No Kubernetes expertise required.
Prerequisites
- Node.js 20+ installed locally
- A GitHub account
- PandaStack CLI:
npm install -g @pandastack/cli
Step 1 — Create Your Express App
If you already have a project, skip ahead. Otherwise, scaffold a minimal API:
mkdir my-express-api && cd my-express-api
npm init -y
npm install express
mkdir srcCreate src/index.js:
const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;
app.use(express.json());
app.get('/health', (req, res) => res.json({ status: 'ok' }));
app.get('/api/hello', (req, res) => {
res.json({ message: 'Hello from PandaStack!' });
});
app.listen(PORT, '0.0.0.0', () => {
console.log(`Server running on port ${PORT}`);
});Add a start script to package.json:
{
"scripts": {
"start": "node src/index.js"
}
}Step 2 — Write a Production Dockerfile
PandaStack deploys Docker containers. Create a Dockerfile at the project root:
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
EXPOSE 3000
CMD ["node", "src/index.js"]Use the Alpine base image to keep the layer small. The --omit=dev flag strips development dependencies from the final image, which matters for security surface area and image size.
Add a .dockerignore to keep the build context clean:
node_modules
.env
*.logTest the build locally before pushing:
docker build -t my-express-api .
docker run -p 3000:3000 my-express-api
curl http://localhost:3000/healthStep 3 — Configure pandastack.json
Create a pandastack.json at the project root:
{
"type": "container",
"healthCheckPath": "/health"
}The healthCheckPath tells PandaStack which endpoint to poll after deploy. If it returns a non-200 status, the platform rolls back automatically — protecting your users from broken releases.
Step 4 — Connect GitHub and Deploy
Push your project to a GitHub repository:
git init
git add .
git commit -m "Initial Express API"
gh repo create my-express-api --public --source=. --pushThen deploy via the CLI:
panda deployThe CLI will prompt you to log in and select or create a project. Alternatively, log in to [dashboard.pandastack.io](https://dashboard.pandastack.io), click New Project, connect your GitHub repository, and PandaStack will detect the Dockerfile and deploy automatically.
Every subsequent git push to your default branch triggers a new deployment.
Step 5 — Add Environment Variables
Never hardcode secrets. In the PandaStack dashboard, navigate to your project → Environment Variables and add:
DATABASE_URL=postgres://user:password@host:5432/mydb
JWT_SECRET=your-secret-key
NODE_ENV=productionThese are injected at runtime and never baked into your image.
Step 6 — Provision a Database (Optional)
If your API needs a database, PandaStack supports PostgreSQL, MySQL, Redis, and MongoDB:
panda db create --type postgres --name my-api-dbThe connection string is automatically added to your project's environment variables.
Verify the Deployment
Once deployed, PandaStack provides a live HTTPS URL. Test it:
curl https://my-express-api.pandastack.io/api/hello
# {"message":"Hello from PandaStack!"}Check deployment logs from the dashboard or CLI:
panda logs --followWhen to Use a Cronjob with Express
If your API needs scheduled background work — sending emails, cleaning up stale records, syncing data from a third-party API — PandaStack supports cronjobs natively. Create a separate script and configure it in the PandaStack dashboard to run on a schedule without keeping a worker process always running:
# Example: a cleanup script you register as a PandaStack cronjob
node src/jobs/cleanup.jsPandaStack also supports edge functions (Node.js via OpenWhisk) for lightweight, event-driven compute — useful for webhook handlers and short-lived tasks.
Summary
You now have a production Express.js API running on PandaStack with automatic deployments on every push, health-check-based rollbacks, and managed environment variables. Read the full reference at [docs.pandastack.io](https://docs.pandastack.io).