Getting Started
Zero to deployed API in 5 minutes.
Prerequisites
- Node.js 24+, pnpm 9+
- AWS credentials configured
- Docker (for container Lambdas only)
1. Scaffold
bash
npx create-mantle-app my-api
cd my-apiSelect a template when prompted:
| Template | Use when |
|---|---|
minimal | Single Lambda, no database |
api | REST API with auth and database |
full | All features enabled |
Skip prompts:
bash
npx create-mantle-app my-api --template=api --database=aurora-dsql --auth=better-auth2. Write a Handler
typescript
// src/lambdas/api/items/index.get.ts → GET /items
import { buildValidatedResponse } from '@mantleframework/core'
import { defineApiHandler, z } from '@mantleframework/validation'
const ResponseSchema = z.object({
items: z.array(z.object({ id: z.string(), name: z.string() })),
})
const api = defineApiHandler({ auth: 'bearer' })
export const handler = api(async ({ context }) => {
return buildValidatedResponse(context, 200, { items: [] }, ResponseSchema)
})File-system routing: src/lambdas/api/<path>/<name>.<method>.ts maps to <method> /<path>/<name>.
3. Develop
bash
mantle dev # local server with hot reload
pnpm test # run tests
mantle check # lint + convention rules4. Build & Deploy
bash
mantle build # bundle all Lambdas
mantle deploy --stage staging # push to AWSmantle deploy runs OpenTofu under the hood — it provisions Lambda functions, API Gateway routes, and all supporting infrastructure from your mantle.config.ts.
Project Layout
my-api/
src/
lambdas/
api/ # file-system routed API handlers
eventbridge/ # EventBridge-triggered handlers
scheduled/ # CloudWatch scheduled handlers
standalone/ # direct-invocation handlers
entities/ # Drizzle schema definitions
migrations/ # database migrations
mantle.config.tsNext Steps
- Handlers —
defineApiHandler,defineEventBridgeHandler,defineScheduledHandler - Database — Aurora DSQL, Aurora Serverless v2, Neon
- Deployment — build options, deploy stages, rollback
- Infrastructure — OpenTofu modules reference