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

Introduction

Functions are a core part of Inngest - it's how you run your own code. Functions are run either automatically when events are received, on a schedule, or manually by people on your team. They're the programmable part of the platform that allow you to build automated systems with zero infra.

With Inngest, you can build and deploy your own custom functions in two ways: via the Inngest CLI or via our web IDE. We'll walk through the basics of a function on the Inngest platform:

  1. The trigger
  2. Your code
  3. The function response

The trigger

Every function on Inngest has a trigger. There can be 2 types of triggers:

  • An Event - The function will be run when a specific event is recieved by Inngest. Each function can have 1 or more event triggers.
  • A Schedule - The function will be run on a schedule that you declare, in crontab schedule format.

Your code

You can write your own code in any language you prefer. Inngest supports anything that you can put in a Docker container, so if you're familiar with writing a Dockerfile, you can run whatever you want on Inngest. Alternatively, you can write simple Node.js functions right from the Inngest web IDE.

We've designed a fantastic workflow with our cli that enables you to quickly create, test, and deploy your functions in any language.

The function response

Steps in your function should always return a JSON-encoded response to stdout; we'll capture the last line of output. As we prefer standards over custom implementations, it's best to return an HTTP-like response:

{
status: 200,
body: { ... }, // Your data
}

This allows us to properly inspect the response, plus the classification of function errors. You can read documentation on function inputs and outputs here.