Introducing the Inngest TypeScript / JavaScript SDK
Join our Discord
Sign up for free

Express

You can host Inngest functions directly as an Express route. In order to deploy with express, you need to:

  1. Serve your functions in a new route via middleware
  2. Register your functions with Inngest after deploying to your hosting service

Serving functions in Express

Import serve from the inngest package to create middleware for Express:

ts
import express from "express";
// Import serve from inngest
import { serve, createFunction } from "inngest";
 
const app = express();
 
// You'd usually have your functions defined in a separate file and imported here.
const exampleFn = createFunction(
"The name of my function",
"app/user.created",
({ event }) => { return { body: "hello!" }; }
);
 
// Create an endpoint for Inngest functions
const inngestMiddleware = serve("My app/service name", process.env.INNGEST_SIGNING_KEY || "", [exampleFn]);
 
// Use the middleware from Inngest to host at /api/inngest.
app.use("/api/inngest", inngestMiddleware);
 
app.listen(3006, () => { console.log("running"); });

This hosts an API endpoint at ${your-url}/api/inngest, which we'll use to call your functions.

serve syntax

serve(appName, signingKey, [functions]);

serve arguments

  • appName: The name of your app or microservice, used to group all functions together
  • signingKey: The signing key for your workspace, available in your account
  • [functions]: An array of all functions to enable

Registering your functions with Inngest

By default, Inngest doesn't know which functions you're serving or the URL of your app. Once you deploy your site to production, you'll need to reigster your functions with Inngest. You can do this via the UI or via an API call.

Registering via the UI

You can add your endpoint’s URL to Inngest via the dashboard:

Registering via the API

You can register your function’s endpoints with a single PUT call to your function endpoint:

bash
curl -X PUT https://www.example.com/api/inngest

Remember to swap www.example.com with your own domain name.

You can read more about registering functions here.