inngest-middleware

Implement Inngest middleware for logging, encryption, error tracking, and dependency injection.

Updated Jun 22, 2026
One-click install
npx skills add https://github.com/aashahin/ai-skills --skill inngest-middleware-aashahin
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: inngest-middleware
Source: https://github.com/aashahin/ai-skills/tree/main/inngest-middleware
Command: npx skills add https://github.com/aashahin/ai-skills --skill inngest-middleware-aashahin

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires inngest, @inngest/middleware-encryption, @inngest/middleware-sentry, and includes references (resource) components.

What problem does it solve? Adding cross-cutting concerns like logging, error tracking, encryption, and shared service clients to every Inngest function individually leads to duplicated code and inconsistent behavior. This Skill shows how to centralize those concerns using Inngest's v4 middleware lifecycle hooks. ## Core Features & Use Cases - Custom Middleware Creation: Build middleware with InngestMiddleware using lifecycle hooks like onFunctionRun, beforeExecution, transformInput, and transformOutput. - Dependency Injection: Share clients like OpenAI, Prisma, Stripe, or Redis across all functions using the built-in dependencyInjectionMiddleware or custom patterns, including lazy, scoped, and conditional injection. - Official Middleware Packages: Integrate @inngest/middleware-encryption for payload encryption with key rotation and @inngest/middleware-sentry for error tracking and tracing. - Use Case: You need Sentry error capture, structured logging, and a shared database client across 30 durable functions. Register three middleware at the client level once instead of modifying every function handler. ## Quick Start Add Sentry error tracking and a shared Prisma client to all my Inngest functions using middleware.

Frequently Asked Questions about inngest-middleware

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add middleware to Inngest functions?▼

Create an InngestMiddleware instance with lifecycle hooks like onFunctionRun and transformOutput, then pass it to the middleware array on the Inngest client or on individual functions. Client middleware runs first, followed by function-level middleware in order.

How do I inject dependencies into Inngest function handlers?▼

Use the built-in dependencyInjectionMiddleware from the inngest package, passing clients like OpenAI or Prisma as an object. Those dependencies then appear directly in each function's handler context without manual wiring.

Does Inngest v4 still need @inngest/realtime middleware?▼

No. Inngest v4 ships realtime natively via step.realtime.publish, so no middleware is required. Installing @inngest/realtime on a v4 project causes a TypeError: Cls is not a constructor at runtime.

How do I encrypt Inngest event and step data?▼

Install @inngest/middleware-encryption and register encryptionMiddleware with an encryption key. It encrypts all step data, function output, and the event data.encrypted field, and supports key rotation through fallbackDecryptionKeys.

Why is my Inngest middleware crashing my functions?▼

Middleware errors propagate into function execution if unhandled. Wrap middleware logic in try-catch blocks and return the original result on failure so a logging or tracking failure never breaks the function itself.

Can I use Inngest middleware in Python?▼

Yes. Python middleware subclasses inngest.Middleware and implements methods like transform_input to inject dependencies into the context. Core lifecycle concepts match the TypeScript API, though hook names differ.