Skip to main content

Deploy Express & Node.js on WebStadia

WebStadia supports deploying Express, Fastify, NestJS, and other Node.js backends as serverless functions.

How it works

Your Express app runs on AWS Lambda behind WebStadia's global CDN. WebStadia automatically:

  1. Detects your framework from package.json
  2. Installs dependencies
  3. Bundles your app using @vercel/nft (only includes files your app actually uses)
  4. Wraps it with @vendia/serverless-express for Lambda compatibility
  5. Deploys to a Lambda function with a public URL

Your app is accessible via your-site.subsite.cc or a custom domain.

Quick start

1. Create an Express app

// index.js
const express = require('express');
const app = express();

app.get('/', (req, res) => {
res.json({ hello: 'world' });
});

app.get('/api/users', (req, res) => {
res.json([{ id: 1, name: 'Alice' }]);
});

// Important: export the app for serverless
module.exports = app;

// Also listen for local development
if (require.main === module) {
app.listen(3000, () => console.log('Listening on 3000'));
}

2. Deploy

Zip your project (including package.json and node_modules) and upload, or connect your GitHub repo.

WebStadia auto-detects Express from your package.json dependencies and handles the rest.

3. Build settings

SettingValue
Build Command(none needed for Express)
Install Commandnpm install

If your project uses TypeScript or has a build step:

SettingValue
Build Commandnpm run build
Entry pointdist/index.js

Supported frameworks

WebStadia auto-detects and supports:

FrameworkDetection
Expressexpress in dependencies
Fastifyfastify in dependencies
NestJS@nestjs/core in dependencies
Koakoa in dependencies
Hapi@hapi/hapi in dependencies

Entry point resolution

WebStadia looks for your app's entry point in this order:

  1. dist/index.js (TypeScript builds)
  2. build/index.js
  3. index.js
  4. app.js
  5. server.js
  6. src/index.js

Your entry point must export the Express app (or an HTTP handler):

// ✅ Works
module.exports = app;

// ✅ Also works
module.exports.default = app;
module.exports.app = app;

Environment variables

Set environment variables in Settings → Build Environment Variables. They're available at runtime via process.env:

const dbUrl = process.env.DATABASE_URL;
const apiKey = process.env.API_KEY;

WebStadia automatically sets:

  • NODE_ENV=production
  • WEBSTADIA_WEBSITE_ID=your-website-id

Lambda configuration

Default settings (configurable per website):

SettingDefault
RuntimeNode.js 20.x
Memory256 MB
Timeout30 seconds
Regionus-east-1

Limitations

  • No WebSocket support - Lambda functions are stateless. Use a separate WebSocket service if needed.
  • Cold starts - First request after inactivity takes ~500ms-2s. Subsequent requests are fast.
  • 30-second timeout - Long-running requests will be terminated. For background jobs, use a queue.
  • No persistent filesystem - Lambda has a temporary /tmp directory (512 MB) that's cleared between invocations.
  • Request body limit - 6 MB for synchronous invocations.

NestJS example

// main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}

// Export for serverless
export default bootstrap;

Build settings for NestJS:

SettingValue
Build Commandnpm run build
Install Commandnpm install