Nest

How to set up Kafka transport in NestJS microservices for event-driven scaling?

March 18, 2026

download ready
Thank You
Your submission has been received.
We will be in touch and contact you soon!

NestJS supports Kafka via @nestjs/microservices with Transporters.KAFKA. Configure MicroserviceOptions with brokers, consumer groups, and topics; use @MessagePattern() for handlers. Scales to 10k+ TPS with partitioning.

Example:-

Code

// main.ts
await NestFactory.createMicroservice(AppModule, {
  transport: Transport.KAFKA,
  options: { client: { brokers: ['localhost:9092'] } }
});
      
Hire Now!

Need Help with Nest Development ?

Work with our skilled nest developers to accelerate your project and boost its performance.
**Hire now**Hire Now**Hire Now**Hire now**Hire now

How to set up Kafka transport in NestJS microservices for event-driven scaling?

NestJS supports Kafka via @nestjs/microservices with Transporters.KAFKA. Configure MicroserviceOptions with brokers, consumer groups, and topics; use @MessagePattern() for handlers. Scales to 10k+ TPS with partitioning.

Example:-

Code

// main.ts
await NestFactory.createMicroservice(AppModule, {
  transport: Transport.KAFKA,
  options: { client: { brokers: ['localhost:9092'] } }
});