Skip to content

Deploy to Production

Get your DeltaBase application live

This guide walks you through deploying your DeltaBase application to production.


  • A DeltaBase account (sign up)
  • Your application code ready to deploy
  • Node.js 18+ installed

  1. Sign in to the DeltaBase Panel
  2. Select or create your organization
  3. Go to API Keys in the sidebar
  4. Click Create API Key
  5. Give it a name (e.g., “Production Deployment”)
  6. Copy the key - you won’t see it again!

Important: Store your API key securely. Never commit it to version control.


Create a deltabase.config.ts file in your project:

import type { InfrastructureConfig as DeltaBaseConfig } from '@delta-base/server';
const config: DeltaBaseConfig = {
eventStores: [
{
name: process.env.DELTABASE_EVENT_STORE_NAME || 'my-app-production',
description: 'Production event store',
subscriptions: [
// Add your projections here
{
id: 'my-projection',
eventFilter: ['user.*', 'order.*'],
subscriberType: 'webhook',
webhook: {
url: `${process.env.SERVICE_URL}/api/projections/events`,
headers: {
Authorization: `Bearer ${process.env.PROJECTION_AUTH_TOKEN}`,
},
retryPolicy: {
maxAttempts: 5,
backoffMinutes: 2,
},
},
},
],
},
],
};
export default config;

Create environment variables for your production environment:

Terminal window
# DeltaBase connection
DELTABASE_API_KEY=db:prod:org-xxx:your-api-key
DELTABASE_BASE_URL=https://api.delta-base.com
DELTABASE_EVENT_STORE_NAME=my-app-production
# Your service URL (for webhooks)
SERVICE_URL=https://my-app.example.com
# Projection authentication
PROJECTION_AUTH_TOKEN=your-secret-projection-token

Set the API key for infrastructure deployment:

Terminal window
export DELTABASE_API_KEY=db:prod:org-xxx:your-api-key

Deploy your event stores and subscriptions:

Terminal window
# Preview changes first
pnpx @delta-base/cli deploy --dry-run
# Deploy for real
pnpx @delta-base/cli deploy

You should see output like:

Deploying DeltaBase infrastructure...
Event Stores:
✓ my-app-production (created)
Subscriptions:
✓ my-projection (created)
Deployment complete!

Update your DeltaBase client to use production settings:

import { DeltaBase } from '@delta-base/server';
// Production configuration
const deltabase = new DeltaBase({
apiKey: process.env.DELTABASE_API_KEY,
baseUrl: process.env.DELTABASE_BASE_URL || 'https://api.delta-base.com',
});
const eventStore = deltabase.getEventStore(
process.env.DELTABASE_EVENT_STORE_NAME
);
// Now use eventStore as normal
await eventStore.appendToStream('user-123', [{
type: 'user.created',
data: { name: 'Alice', email: 'alice@example.com' },
}]);

A common pattern is to switch based on environment:

import { DeltaBase } from '@delta-base/server';
const isProduction = process.env.NODE_ENV === 'production';
const deltabase = new DeltaBase({
apiKey: isProduction ? process.env.DELTABASE_API_KEY : undefined,
baseUrl: isProduction
? 'https://api.delta-base.com'
: 'http://localhost:8787',
});

Deploy your application to your hosting provider. Here are examples for common platforms:

Terminal window
# Set secrets
wrangler secret put DELTABASE_API_KEY
wrangler secret put PROJECTION_AUTH_TOKEN
# Deploy
wrangler deploy

Your wrangler.jsonc:

{
"name": "my-app",
"main": "src/index.ts",
"compatibility_date": "2024-01-01",
"vars": {
"DELTABASE_BASE_URL": "https://api.delta-base.com",
"DELTABASE_EVENT_STORE_NAME": "my-app-production"
}
}
Terminal window
# Set environment variables
vercel env add DELTABASE_API_KEY production
vercel env add DELTABASE_BASE_URL production
vercel env add DELTABASE_EVENT_STORE_NAME production
vercel env add PROJECTION_AUTH_TOKEN production
# Deploy
vercel --prod
FROM node:20-alpine
WORKDIR /app
COPY . .
RUN npm install
ENV DELTABASE_BASE_URL=https://api.delta-base.com
CMD ["npm", "start"]

Run with:

Terminal window
docker run -e DELTABASE_API_KEY=your-key \
-e DELTABASE_EVENT_STORE_NAME=my-app-production \
-e PROJECTION_AUTH_TOKEN=your-token \
my-app

Use the DeltaBase Panel to verify your event store is working:

  1. Go to app.delta-base.com
  2. Select your organization
  3. Find your event store in the list
  4. Check the event count and status

Send a test event from your deployed application:

const result = await eventStore.appendToStream('test-stream', [{
type: 'test.event',
data: { message: 'Production deployment successful!' },
}]);
console.log('Event appended, global position:', result.globalPosition);

If you have projections:

  1. Append an event that matches your subscription filter
  2. Check your webhook endpoint logs
  3. Verify the event was received and processed

Before going live, verify:

  • API key is set and working
  • Event store is created (pnpx @delta-base/cli deploy)
  • Application can append events
  • Webhook URLs are publicly accessible
  • Projection authentication is configured
  • Error handling is in place
  • Monitoring/logging is set up

The Panel provides built-in monitoring:

  • Event counts and throughput
  • Subscription health and delivery status
  • Stream statistics
  • Error logs

Log important operations:

try {
const result = await eventStore.appendToStream(streamId, events);
console.log(`Appended ${events.length} events to ${streamId}`, {
globalPosition: result.globalPosition,
version: result.nextExpectedStreamVersion,
});
} catch (error) {
console.error('Failed to append events', {
streamId,
error: error.message,
});
throw error;
}

Add a health check endpoint:

app.get('/health', async (c) => {
try {
// Test DeltaBase connection
await eventStore.readStream('health-check', { limit: 1 });
return c.json({ status: 'healthy', deltabase: 'connected' });
} catch (error) {
return c.json({ status: 'unhealthy', error: error.message }, 500);
}
});

  • Verify the API key is correct
  • Check it hasn’t been revoked
  • Ensure you’re using the production key (not a development key)
  • Run pnpx @delta-base/cli deploy to create the event store
  • Verify DELTABASE_EVENT_STORE_NAME matches your config
  • Verify your webhook URL is publicly accessible
  • Check your server is running and healthy
  • Verify PROJECTION_AUTH_TOKEN is set correctly on both sides
  • Check server logs for errors
  • DeltaBase has rate limits to protect the service
  • Implement exponential backoff in your application
  • Contact support if you need higher limits