New: HCEL — chain prompts, RAG, and agents in native TypeScript Learn more →
HazelJS LogoHazelJS

Comparison

HazelJS vs NestJS

NestJS is excellent for structured APIs. HazelJS keeps a familiar module/DI model and adds native AI, agents, RAG, and Agent OS in the same stack.

Updated August 4, 2026

HazelJS vs NestJS

TL;DR

  • NestJS is a proven TypeScript framework for APIs and microservices — excellent structure, mature ecosystem.
  • AI on NestJS usually means bolting on LangChain, Vercel AI SDK, or custom OpenAI clients yourself.
  • HazelJS keeps Nest-style modules, decorators, and DI, and ships Agent Runtime, RAG, HCEL, and Agent OS in the same stack.
  • Choose NestJS when you only need classic backends or are deeply locked into Nest packages.
  • Choose HazelJS when your product is agents, RAG, or AI APIs — not an afterthought.

Who this is for

You should read this if you:

  • Know NestJS and want AI without a second framework
  • Are evaluating NestJS alternatives for LLM / agent backends
  • Want one DI container for HTTP controllers and agents

Stay on NestJS if you:

  • Ship mostly CRUD/API services with little AI
  • Depend heavily on Nest-specific community modules you cannot replace yet
  • Cannot afford a migration window for an existing large Nest monorepo

The problem NestJS does not solve alone

NestJS gives you controllers, providers, modules, guards, and pipes. For AI you still assemble:

  1. An LLM SDK (OpenAI, Anthropic, …)
  2. A chain/agent library (often LangChain)
  3. Vector DB + loaders + embeddings
  4. Session/memory stores
  5. Eval, guardrails, cost tracking, and tracing

That stack works — and it is a lot of glue. Teams end up with two mental models: Nest for HTTP, LangChain for AI.

Side-by-side comparison

AspectNestJSHazelJS
Backend structureDecorators, DI, modules — matureSame patterns — familiar if you know Nest
AI & agentsBring your own (LangChain, Vercel AI SDK, …)Native Agent Runtime + Agent OS
Agent stateManual session/store wiringRich AgentState, Redis persistence, onState hooks
RAGIntegrate loaders, embedders, vector DBs separatelyAgentic RAG, GraphRAG, loaders, vector stores built in
OrchestrationManual services or external LCELHCEL fluent pipelines inside the same DI graph
ObservabilityDIY OpenTelemetry / custom cost trackingInspector timelines + OpenTelemetry + LLM cost hooks
Guardrails & evalThird-party or roll your own@hazeljs/guardrails, @hazeljs/eval, @hazeljs/testing
Time to first agent APIDays of framework + libs + glueMinutes with CLI templates or a few packages
ServerlessManual adapters@hazeljs/serverless for Lambda & Cloud Functions

Code: Nest-style HTTP vs AI-native controller

Classic Nest-style controller feel in HazelJS:

import { Controller, Get, Post, Body, HazelModule } from '@hazeljs/core';
import { AITask } from '@hazeljs/ai';

@Controller({ path: '/chat' })
class ChatController {
  @AITask({ provider: 'openai', model: 'gpt-4o' })
  @Post()
  async chat(@Body() body: { message: string }) {
    return body.message;
  }

  @Get('health')
  health() {
    return { ok: true };
  }
}

@HazelModule({ controllers: [ChatController] })
export class AppModule {}

Agent with tools (no separate LangChain executor):

import { Agent, Tool } from '@hazeljs/agent';

@Agent({
  name: 'support-agent',
  systemPrompt: 'You are a helpful support agent.',
  enableMemory: true,
  enableRAG: true,
})
export class SupportAgent {
  @Tool({
    description: 'Look up order by ID',
    parameters: [{ name: 'orderId', type: 'string', required: true }],
  })
  async lookupOrder(input: { orderId: string }) {
    return { status: 'shipped', trackingNumber: 'TRACK123' };
  }
}

Architecture decision

If you need…Prefer
Large existing Nest codebase, little AINestJS
New AI-native backend in TypeScriptHazelJS
Nest HTTP + serious agents/RAGNestJS + LangChain or HazelJS (see NestJS + LangChain vs HazelJS)
Edge-first / multi-runtime onlyHono / similar (not HazelJS’s primary target)

When NestJS is the better choice

Be honest with the tradeoff:

  • Ecosystem gravity — Nest has more tutorials, jobs, and community packages.
  • Team familiarity — rewriting working Nest services for AI you barely need is waste.
  • Non-AI microservices — HazelJS still works, but Nest’s maturity may win on politics and hiring.

HazelJS wins when AI is a core product surface, not a side feature.

Migration path

Patterns map closely: modules → modules, providers → providers, controllers → controllers. Add @hazeljs/ai / @hazeljs/agent / @hazeljs/rag for AI slices first.

→ Full walkthrough: Migrate from NestJS to HazelJS.

FAQ

See the FAQ section on this page for structured answers (also exposed as FAQ schema for search).

Next steps

  1. Install HazelJS
  2. Read Introduction and Agent OS
  3. Compare the common combo stack: NestJS + LangChain vs HazelJS
  4. Browse packages: Agent, AI, RAG
  5. Star / clone: github.com/hazel-js/hazeljs

FAQ

Is HazelJS a NestJS fork?
No. HazelJS is an independent TypeScript framework inspired by Nest-style decorators and modules, built AI-native from day one rather than bolting AI onto a classic HTTP framework.
Can I use HazelJS with LangChain?
You can call external libraries from HazelJS services if you need to, but most teams replace LangChain glue with @hazeljs/ai, @hazeljs/agent, @hazeljs/rag, and HCEL so HTTP and AI share one DI container.
When should I stay on NestJS?
Stay on NestJS if your team is deeply invested in the Nest ecosystem, you only need classic APIs without agents/RAG, or migrating a large Nest codebase is not worth the short-term cost.
How hard is migration from NestJS?
Controllers, modules, providers, and decorator patterns map closely. AI features are additive. See the NestJS migration guide for side-by-side patterns.
Does HazelJS support Prisma, GraphQL, and gRPC?
Yes — via @hazeljs/prisma, @hazeljs/graphql, and @hazeljs/grpc, plus gateway, resilience, and discovery packages for microservices.
Is HazelJS production-ready?
HazelJS 1.x ships stable semver on npm latest across the @hazeljs/* package set, with CI on current Node LTS lines. Evaluate with your SLOs like any framework adoption.

Docs & next steps

Related comparisons

  • NestJS + LangChain vs HazelJS

    The common production path — NestJS for HTTP and LangChain for AI — works, but creates two paradigms. HazelJS unifies APIs, agents, and RAG in one module system.

  • HazelJS vs Express

    Express maximizes freedom with middleware. HazelJS maximizes structure for TypeScript AI backends — controllers, DI, and AI packages included.

  • HazelJS vs LangChain

    LangChain composes LLM pipelines. HazelJS ships those capabilities inside a production TypeScript backend — controllers, agents, RAG, and ops together.

← All comparisons