- Регистрация
- 1 Мар 2015
- Сообщения
- 1,481
- Баллы
- 155
What is Inngest?
Inngest is an event-driven background job platform designed to work seamlessly with modern frameworks and serverless environments. It allows you to build durable, asynchronous workflows using events and functions, similar to AWS Step Functions, but with a more developer-friendly DX.
Key Features
Event-based: Trigger functions using custom events (user.signed_up, order.placed, etc.).
Install Inngest
npm install inngest
Initialize Inngest Client
// inngest.ts
import { Inngest } from "inngest";
export const inngest = new Inngest({ name: "My App" });
Create an Event-Driven Function
// functions/userSignup.ts
import { inngest } from "../inngest";
export const sendWelcomeEmail = inngest.createFunction(
{ id: "send-welcome-email" },
{ event: "user.signed_up" },
async ({ event }) => {
// your logic here
console.log(`Welcome ${event.data.email}!`);
}
);
Serve Functions in Your App
For Next.js:
// pages/api/inngest.ts
import { serve } from "inngest/next";
import { sendWelcomeEmail } from "../../functions/userSignup";
import { inngest } from "../../inngest";
export default serve(inngest, [sendWelcomeEmail]);
Local Development
Install Inngest Dev CLI
npm install --global inngest-cli
Start Dev Server
inngest dev
Use the Dev UI or CLI to trigger events:
inngest send --name user.signed_up --data '{"email":"test@example.com"}'
? Tips for Development
Step Functions: You can add delays or conditional steps in workflows using the step.run API.
Debugging: Use the Inngest Dev dashboard to view function execution, logs, and step state.
Retries: Automatic retrying is handled for failed steps unless configured otherwise.
Environment separation: Use different Inngest apps for development, staging, and production.
Inngest is an event-driven background job platform designed to work seamlessly with modern frameworks and serverless environments. It allows you to build durable, asynchronous workflows using events and functions, similar to AWS Step Functions, but with a more developer-friendly DX.
Key Features
Event-based: Trigger functions using custom events (user.signed_up, order.placed, etc.).
Durable workflows: Built-in retries, step execution, and time-based delays.
Local development: Use the Inngest Dev Server to test workflows without deploying.
Framework-agnostic: Works with Next.js, Express, and other frameworks.
Strong typing: Full TypeScript support for event payloads and responses.
Install Inngest
npm install inngest
Initialize Inngest Client
// inngest.ts
import { Inngest } from "inngest";
export const inngest = new Inngest({ name: "My App" });
Create an Event-Driven Function
// functions/userSignup.ts
import { inngest } from "../inngest";
export const sendWelcomeEmail = inngest.createFunction(
{ id: "send-welcome-email" },
{ event: "user.signed_up" },
async ({ event }) => {
// your logic here
console.log(`Welcome ${event.data.email}!`);
}
);
Serve Functions in Your App
For Next.js:
// pages/api/inngest.ts
import { serve } from "inngest/next";
import { sendWelcomeEmail } from "../../functions/userSignup";
import { inngest } from "../../inngest";
export default serve(inngest, [sendWelcomeEmail]);
Local Development
Install Inngest Dev CLI
npm install --global inngest-cli
Start Dev Server
inngest dev
Send Test EventsThis spins up a local dashboard and event relay server. It watches your local functions and simulates the production environment.
Use the Dev UI or CLI to trigger events:
inngest send --name user.signed_up --data '{"email":"test@example.com"}'
? Tips for Development
Step Functions: You can add delays or conditional steps in workflows using the step.run API.
Debugging: Use the Inngest Dev dashboard to view function execution, logs, and step state.
Retries: Automatic retrying is handled for failed steps unless configured otherwise.
Environment separation: Use different Inngest apps for development, staging, and production.