Overview
The Inngest provider extends your application ports with background job and event capabilities using Inngest. It enables reliable event-driven workflows and background processing for your Contract Kit applications.Installation
Configuration
The Inngest provider reads configuration from environment variables:| Variable | Required | Description | Default |
|---|---|---|---|
INNGEST_APP_NAME | No | Friendly application name shown in Inngest | "contract-kit-app" |
INNGEST_EVENT_KEY | No | Event key / signing key for Inngest Cloud | - |
INNGEST_EVENT_KEY is required when using Inngest Cloud for production deployments.Example .env
Setup
Basic Setup
Type Your Ports
To get proper type inference for the inngest port, extend your ports type:API Reference
The provider extends your ports with aninngest property:
send<TData>(args)
Send an event to Inngest.
args.name: Event nameargs.data: Event data
Promise<void>
client
Access the underlying Inngest client for advanced operations like defining functions.Inngest
Usage Examples
Sending Events in Use Cases
Wiring Domain Events to Inngest Jobs
This provider does NOT automatically subscribe to domain events. This is intentional to keep the provider generic and reusable. To wire domain events to Inngest jobs, create a separate jobs provider in your application:- Framework-level provider (
inngestProvider) - Inngest integration - App-level provider (
jobsProvider) - Business job logic
Defining Inngest Functions
Inngest functions (the handlers that process events) should be defined separately from your Contract Kit application, typically in a separate API route or serverless function:Lifecycle
The Inngest provider:- During
register:- Creates Inngest client
- Adds the
inngestport
- No cleanup needed: Inngest client doesn’t require explicit shutdown
Error Handling
The provider will throw errors in these cases:- Missing required configuration (though all fields have defaults or are optional)
- Invalid configuration values
Local Development
For local development, you can run the Inngest Dev Server:http://localhost:8288 where you can:
- View events
- Trigger functions
- Debug execution
Best Practices
Keep event payloads small
Keep event payloads small
Send only necessary data in events. Large payloads can cause performance issues.
Use descriptive event names
Use descriptive event names
Follow a consistent naming pattern like
entity.action (e.g., user.invited, order.created).Make functions idempotent
Make functions idempotent
Design your Inngest functions to handle duplicate events gracefully.
Use steps for complex workflows
Use steps for complex workflows
Break down complex jobs into steps using
step.run() for better visibility and retry control.Separate concerns
Separate concerns
Keep Inngest integration (framework-level) separate from your business job logic (app-level).