System theme
AI agents

Express in the Age of AI: Why It's Being Left Behind

AI‑generated code favors async‑typed frameworks; Express’s loose API and legacy middleware make it a poor fit for modern LLM‑assisted development.

KK13 · 2 min read

Express isn't being replaced by AI — it's being left behind because the ecosystem has moved to async-native, typed, and AI-friendly frameworks. While large language models can generate code, they also highlight the friction in older APIs.

AI-generated code prefers modern patterns

Copilot, Cursor, and similar tools are trained on recent GitHub code. Their suggestions favor:

  • Async/await arrow functions
  • TypeScript interfaces
  • Framework-specific helpers (Fastify decorators, Hono middleware, Elysia macros)

When you start typing app.get in an Express project, the AI often suggests wrapping the handler in a try/catch or using express-async-errors — a sign the pattern is considered boilerplate.

In a Fresh/Hono/Elysia file, the same prompt yields:

// Hono + AI
app.get('/users/:id', async (c) => {
  const user = await db.users.find(c.req.param('id'));
  if (!user) return c.text('Not found', 404);
  return c.json(user);
});

No extra ceremony. The AI treats the framework as part of the language.

Typed contracts make AI more reliable

LLMs hallucinate less when they have strict types. Frameworks built in TypeScript (Hono, Elysia, oRPC) give the model:

  • Known shape of c.req (params, query, body, headers)
  • Known return shape (Response or void)
  • Zod schemas that the AI can read and respect

Express’s loosely typed req: Request (any-heavy) forces the model to guess, leading to more mistakes.

Middleware composability = easier AI refactoring

AI excels at extracting repeated logic into middleware — but only if the middleware system is composable.

Fastify’s encapsulation, Hono’s middleware returning Response, and Elysia’s macro system let the AI:

  • Extract logging, auth, validation into reusable units
  • Keep type information intact
  • Compose them without guessing order

Express’s linear (req, res, next) chain makes it harder for the AI to infer where to insert a new middleware without breaking error handling.

Performance matters for AI workloads

AI proxies often need high concurrency: streaming tokens, handling many simultaneous requests, or acting as a gateway to model endpoints.

Benchmarks show Express handling roughly half the requests/sec of Fastify or Hono under similar load. When you’re paying per‑token, every millisecond of server overhead cuts into your budget.

The ecosystem shift

Concern Express 4 Modern alternative
AI‑friendly docs Community‑maintained, outdated Official TS docs, AI‑prompt‑ready examples
Plugin model Middleware only Fastify plugins, Hono middleware, Elysia macros — all typed
Serverless / Edge Not designed for it Hono and Elysia run on Cloudflare Workers, Deno, Bun, Vercel Edge
WebSocket + streaming Manual upgrade Built‑in support in Fastify, Hono, Elysia
Validation Joi, express‑validator (imperative) Zod schemas (declarative, AI‑readable)

What to do

If you’re starting a new service that will interact with LLMs (proxy, agent, RAPTOR pipeline, etc.), pick a framework that the AI understands natively.

Fastify – closest to Express mental model, great TypeScript support, plugin ecosystem.

Hono – tiny bundle, works everywhere, excellent for edge/AI gateways.

Elysia – best DX if you’re on Bun, with AI‑friendly macros.

Leave Express for legacy maintenance only. Let the AI help you build the future, not fight the past.