Framework-agnostic HTTP handlers for Trigger.dev – expose your background tasks via REST endpoints in any web framework.
- 🚀 Simple Integration - Drop-in handlers for your existing web framework
- 🎯 Framework Support - Pre-built adapters for Next.js, Hono, and Express
- 📦 Lightweight - Minimal dependencies, tiny bundle size
- 🛠️ TypeScript First - Full type safety and autocompletion
- 🔄 Consistent API - Same pattern across all frameworks
npm install trigger-adaptersOr using your preferred package manager:
yarn add trigger-adapters
pnpm add trigger-adapters
bun add trigger-adapters// app/api/trigger/[id]/route.ts
import { handler } from 'trigger-adapters/nextjs';
export const POST = handler();import { Hono } from 'hono';
import { handler } from 'trigger-adapters/hono';
const app = new Hono();
app.post('/api/trigger/:id', handler());
export default app;import express from 'express';
import { handler } from 'trigger-adapters/express';
const app = express();
app.use(express.json());
app.post('/api/trigger/:id', handler());
app.listen(3000);Trigger Adapters provides a simple, consistent interface for exposing Trigger.dev tasks via HTTP endpoints:
- Extract Task ID from the route parameters
- Parse Request Body to get the task payload
- Trigger the Task using Trigger.dev SDK
- Return Response in the appropriate format for the framework
Each adapter handles framework-specific details like request/response formats, middleware integration, and error handling.
Visit https://trigger-adapters.dev for full documentation, including:
import { handler } from 'trigger-adapters/nextjs';
import { NextRequest, NextResponse } from 'next/server';
import { verifyToken } from '@/lib/auth';
export async function POST(
request: NextRequest,
context: { params: { id: string } }
) {
const token = request.headers.get('Authorization');
if (!token || !await verifyToken(token)) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
return handler()(request, context);
}import { Hono } from 'hono';
import { bearerAuth } from 'hono/bearer-auth';
import { cors } from 'hono/cors';
import { handler } from 'trigger-adapters/hono';
const app = new Hono();
app.use('/api/*', cors());
app.use('/api/trigger/*', bearerAuth({ token: process.env.API_TOKEN }));
app.post('/api/trigger/:id', handler());import express from 'express';
import rateLimit from 'express-rate-limit';
import { handler } from 'trigger-adapters/express';
const app = express();
const limiter = rateLimit({
windowMs: 15 * 60 * 1000,
max: 100
});
app.use(express.json());
app.post('/api/trigger/:id', limiter, handler());This is a monorepo managed with Turborepo and Bun.
trigger-adapters/
├── packages/
│ └── trigger-adapters/ # Main library package
├── apps/
│ └── www/ # Documentation site (VitePress)
└── README.md
# Clone the repository
git clone https://github.com/jackall3n/trigger-adapters.git
cd trigger-adapters
# Install dependencies
bun install
# Build all packages
bun run build
# Run development mode
bun run dev
# Run tests
cd packages/trigger-adapters
bun run test| Command | Description |
|---|---|
bun run build |
Build all packages |
bun run dev |
Start development mode |
bun run check |
Run Biome linter/formatter check |
bun run check:write |
Fix linting/formatting issues |
bun run check-types |
Run TypeScript type checking |
The main library is in packages/trigger-adapters/:
cd packages/trigger-adapters
# Build the library
bun run build
# Watch mode for development
bun run dev
# Run tests
bun run test
# Type checking
bun run typecheck
# Release new version
bun run releaseThe documentation site is in apps/www/:
cd apps/www
# Start dev server
bun run dev
# Build documentation
bun run build
# Preview built docs
bun run previewAll adapters export a handler() function that returns a framework-specific request handler.
import { handler } from 'trigger-adapters/nextjs';
// App Router
export const POST = handler();
// Pages Router
export default handler();import { handler } from 'trigger-adapters/hono';
app.post('/trigger/:id', handler());import { handler } from 'trigger-adapters/express';
app.post('/trigger/:id', handler());- Trigger.dev account and SDK configured
- One of the supported frameworks (Next.js, Hono, Express)
- Node.js 18+ or Bun
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Use Bun as the package manager
- Follow the existing code style (enforced by Biome)
- Add tests for new features
- Update documentation as needed
MIT © Jack Allen
- Built for Trigger.dev
- Inspired by the need for simple, consistent HTTP handlers across frameworks
- Thanks to all contributors and users
Made with ❤️ by Jack Allen