Star
Run it

Deployment

notifkit is a library, not an image. You deploy your own Node service (the one that runs NotifkitServer) next to Postgres and Redis.

Step-by-step guides: AWS and Railway.

The service

import { NotifkitServer } from "notifkit";
import { ResendTransport } from "@notifkit/provider-resend";

const server = new NotifkitServer({
  services: ["all"],
  port: Number(process.env.PORT ?? 3000),
  nodeEnv: "production",
  databaseUrl: process.env.DATABASE_URL, // required in production
  redisUrl: process.env.REDIS_URL,       // required in production
  providers: [new ResendTransport({ apiKey: process.env.RESEND_KEY!, from: "[email protected]" })],
});

await server.start();

Dockerfile

Node 22 or later. notifkit is ESM-only.

FROM node:22-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:22-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY package*.json ./
RUN npm ci --omit=dev && npm cache clean --force
COPY --from=build /app/dist ./dist
USER node
EXPOSE 3000
# Exec form so node gets SIGTERM and drains in-flight sends.
CMD ["node", "dist/server.js"]

Compose

services:
  notifkit:
    build: .
    ports:
      - "3000:3000"
    environment:
      NODE_ENV: production
      HOST: 0.0.0.0
      DATABASE_URL: postgres://notifkit:notifkit@postgres:5432/notifkit
      REDIS_URL: redis://redis:6379
      ADMIN_API_KEY: ${ADMIN_API_KEY:?set ADMIN_API_KEY}
      UNSUBSCRIBE_SECRET: ${UNSUBSCRIBE_SECRET:?set UNSUBSCRIBE_SECRET}
      RESEND_KEY: ${RESEND_KEY}
    depends_on:
      postgres: { condition: service_healthy }
      redis:    { condition: service_healthy }
    stop_grace_period: 45s
    restart: unless-stopped

  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: notifkit
      POSTGRES_PASSWORD: notifkit
      POSTGRES_DB: notifkit
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U notifkit"]
      interval: 10s
    restart: unless-stopped

  redis:
    image: redis:7-alpine
    command: ["redis-server", "--appendonly", "yes"]
    volumes:
      - redisdata:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
    restart: unless-stopped

volumes:
  pgdata:
  redisdata:
docker compose up --build -d

# Then create a project, as in the quickstart:
curl -s -X POST http://localhost:3000/v1/projects \
  -H "Authorization: Bearer $ADMIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"production"}'
Redis must never evict

Keep Redis on maxmemory-policy noeviction (the default). Any other policy silently drops queued messages.

Environment

VariableSet it to
NODE_ENVproduction. Otherwise notifkit tries to start throwaway Docker containers
DATABASE_URLYour Postgres URL. Required
REDIS_URLYour Redis URL. Required
HOST0.0.0.0 in any container. The default 127.0.0.1 refuses outside connections
UNSUBSCRIBE_SECRET16+ random characters. Required. Never rotate it, or every unsubscribe link already sent breaks
ADMIN_API_KEYYour bootstrap key. Enables POST /v1/projects
PUBLIC_URLThe public URL of this API, e.g. https://notify.example.com. Used in unsubscribe links and provider webhooks

Every other setting is optional. See Operations.

Keep port 3000 private

The API accepts any browser origin. Don't expose it directly to the public internet.

More than one replica

Migrations run on start. With several replicas, set autoMigrate: false on all of them and run npx notifkit-migrate once before each rollout.

To split the API from the workers, run the same image with a different services: ["api"] on API replicas and ["enricher", "engine", "delivery", "scheduler", "workflow", "events", "ai"] on workers. Workers have no HTTP port, so don't give them a healthcheck.

Deploying on a PaaS

Railway, Render, Fly and Heroku all work. Deploy your own repo with server.ts and a start script, then:

  • Add Postgres and Redis and set DATABASE_URL and REDIS_URL from them.
  • Set HOST=0.0.0.0 and leave PORT unset. The platform sets it.
  • Health check path: /ready.
  • Pre-deploy command: npx notifkit-migrate.

Installing into a custom PostgreSQL schema

If notifkit shares a database with another app, give it its own schema with DB_SCHEMA=notifications. Use the same value on every service. Set it before the first migration: changing it on a running install doesn't move existing tables.

Need help?

Stuck, or want us to deploy it for you? Email [email protected].