Skip to main content

Framework Integrations

First-class support for popular frameworks.

Available Integrations​

FrameworkPackageFeatures
NestJS@saga-bus/nestjsFull DI, decorators
Next.js@saga-bus/nextjsApp Router, API routes
Express@saga-bus/expressMiddleware, health
Fastify@saga-bus/fastifyPlugin, health
Hono@saga-bus/honoEdge runtime

Choosing an Integration​

NestJS​

Best for enterprise applications with full dependency injection:

@Module({
imports: [SagaBusModule.forRoot({ ... })],
})
export class AppModule {}

Next.js​

Best for serverless and edge deployments:

// app/api/orders/route.ts
import { publishMessage } from '@saga-bus/nextjs';

export async function POST(request: Request) {
await publishMessage({ type: 'OrderSubmitted', ... });
}

Express/Fastify/Hono​

Best for traditional Node.js servers:

import { sagaBusMiddleware } from '@saga-bus/express';

app.use(sagaBusMiddleware({ bus }));

Common Patterns​

Health Checks​

All integrations support health endpoints:

// Express
app.use('/health', createHealthRouter(bus));

// Fastify
fastify.register(sagaBusFastifyPlugin, { bus });

// NestJS
@Module({
imports: [SagaBusModule.forRoot({ healthCheck: true })],
})

Graceful Shutdown​

import { setupGracefulShutdown } from '@saga-bus/express';

setupGracefulShutdown(bus, server);