Rajt – Serverless Bundler Layer for AWS Lambda & Cloudflare Workers

raw JSON →
0.0.106 verified Sat Apr 25 auth: no javascript

Rajt (v0.0.106, pre-1.0) is a TypeScript-native, fully typed serverless framework (not a runtime) that acts as a bundler layer for AWS Lambda (Node.js ≥18, LLRT) and Cloudflare Workers. It provides a router, middleware, and type-safe request/response handling with zero external runtime dependencies. Its key differentiators: single interface across Lambda and Workers, tree-shakable bundler integration, and strict typing that catches misconfigurations at compile time. Active development with frequent releases; not stable yet. Consider alternatives like @aws-lambda-powertools, Hono, or Itty Router for production.

error Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'rajt' imported from ...
cause ESM-only package; using require() or misconfigured bundler/Node.js ES modules.
fix
Ensure package.json has 'type': 'module' and use import syntax. Node.js >=18 required.
error TypeError: (intermediate value).use is not a function
cause Calling router.use() instead of app.use(router).
fix
Use app.use(router) on the Rajt instance.
error TS2339: Property 'requestContext' does not exist on type 'Request'
cause Accessing Lambda-specific properties without type augmentation.
fix
Import and use types from 'rajt/types/aws' as type assertion.
error SyntaxError: Unexpected identifier 'Rajt'
cause Importing rajt using CJS require() or in a CJS context.
fix
Switch to ESM syntax: import { Rajt } from 'rajt'.
breaking Rajt v0.0.106 is pre-1.0 with frequent breaking changes. API surface may change without major version bump.
fix Lock version and watch changelog. Do not use for production-critical applications.
gotcha The Router instance does not support middleware attached directly to it; must use Rajt instance's use() method.
fix Call app.use(router) instead of router.use(middleware).
gotcha Environment-specific features (e.g., AWS Lambda context) require explicit types from 'rajt/types/aws' or 'rajt/types/cloudflare'.
fix Import types: import { LambdaContext } from 'rajt/types/aws';
breaking LLRT support is experimental and may not cover full Lambda API.
fix Test thoroughly on LLRT; file issues if missing features.
gotcha Response objects must follow Web API Response interface; do not use AWS Lambda-style callbacks.
fix Return a standard Response object, e.g., new Response(body, { status: 200 }).
npm install rajt
yarn add rajt
pnpm add rajt

Creates a basic HTTP server using Rajt's router and exports the handler for AWS Lambda or Cloudflare Workers.

import { Rajt, Router } from 'rajt';

const router = new Router();
router.get('/hello', async (req) => {
  return new Response('Hello, World!');
});

const app = new Rajt();
app.use(router);

export const handler = app.handle;