When you start a new TypeScript backend today, you usually face a split:

  1. Minimal edge frameworks (like Hono) give you zero dependencies and great portability, but you spend the first week wiring up validation, JWT/JWKS auth, password hashing, OpenAPI, rate limiting, queues, and OpenTelemetry.
  2. Full-featured frameworks (like NestJS or heavily-plugged Fastify) give you everything out of the box, but pull in dozens to hundreds of transitive npm dependencies and rarely run cleanly on Edge Workers or Deno.

I built BareJS to explore a third option: batteries-included for production, yet zero external runtime dependencies, running the same codebase across Bun, Node.js (uWebSockets.js / node:http), Deno 2, Cloudflare Workers, and AWS Lambda.

1. O(1) JIT Radix Routing — With Automatic No-JIT Fallback

BareJS compiles route trees and middleware pipelines at startup into specialized functions, eliminating per-request array allocations and dynamic lookups. On Bun, single-handler async routes use a Bun.peek fast-path to avoid redundant Promise wrappers.

One real-world constraint of JIT compilers is strict CSP environments or V8 launched with --disallow-code-generation-from-strings. BareJS probes dynamic code evaluation once at startup: if new Function is disallowed, it automatically falls back to interpreted Radix lookup, pipeline execution, and response projection — with zero EvalErrors and zero hot-path overhead when JIT is allowed.

2. Standard Schema v1 + Automatic Response Secret-Stripping

Accidental data leaks (returning passwordHash or internal DB columns) are one of the most common API security bugs. In BareJS, attaching a response schema (TypeBox, Zod, Valibot, or ArkType) compiles a field projector that automatically strips undeclared properties — whether you return a plain object or call return ctx.status(201).json(user).

import { BareJS, Type } from 'barejs'; const app = new BareJS().get('/users/:id', { response: Type.Object({ id: Type.String(), name: Type.String(), }), }, (ctx) => { return ctx.status(200).json({ id: ctx.params.id, name: 'Alice', passwordHash: 'argon2id$...', // automatically stripped }); }); 

3. End-to-End Typed RPC (bareTreaty) + Typed SSE

bareTreaty(app) gives you a chained TypeScript client over HTTP or in-memory (zero network overhead for SSR and tests):

  • Route parameters (:id) are inferred at compile time even without schemas.
  • Inline per-route middlewares preserve full return-type inference.
  • ctx.sse<T>() returns SseResponse<T>, which bareTreaty unwraps as AsyncIterable<T> with AbortSignal cancellation.

4. Production Guardrails Built In

Rather than leaving edge cases to ad-hoc userland code, BareJS includes:

  • LIFO Context Pooling + ctx.detach(): Keeps GC pressure low on the hot path, guards against Use-After-Free in dev mode, and lets you safely detach ctx for background tasks in 1 call.
  • Scoped Resource Cleanup (ctx.defer() & Symbol.asyncDispose): Guarantees DB connections/locks close in LIFO order after the response.
  • Multi-Node Scale via BareStore: Share memoryStore, sqliteStore, upstashStore, or Cloudflare kvStore across rateLimit(), cache(), idempotency(), barejs/workflow, distributed app.cron() locks, and persistent barejs/queue (await queue.restore()).
  • Graceful Rolling Updates (app.shutdownSignal): An AbortSignal that fires as soon as app.drain() or app.stop() begins, so long-lived SSE and AI streams close cleanly.

5. 18 Opt-In Modular Subpaths (0 Bytes When Unused)

Everything beyond core HTTP/WebSockets lives in dedicated subpath exports (barejs/edge, barejs/mcp, barejs/devtools, barejs/otel, barejs/store, barejs/workflow, barejs/queue, barejs/webhooks, barejs/metrics, barejs/ai, barejs/jsx, barejs/ssg, and serverless adapters for AWS Lambda, Cloudflare Pages, and Netlify).

Try It Out

bun create barejs my-app # or npm install barejs 

(Note: BareJS is an independent TypeScript web framework and is not affiliated with Holepunch's Bare JavaScript runtime.)