Announcing our new Vercel integration
Join our Discord
Sign up for free

RedwoodJS

Inngest works with RedwoodJS out of the box, and allows you to write background jobs, scheduled functions, and event-driven systems using RedwoodJS Serverless Functions.

Follow along to learn how to:

  1. Strictly type your functions
  2. Serve your functions with a new API route
  3. Write functions with RedwoodJS
  4. Register your functions with Inngest after deploying

Strictly typing functions

Inngest fully types every event you send, ensuring that your functions and data are always valid. To generate your type library, run:

npx inngest-cli@latest types ts -o ./api/src/__generated__/inngest.ts

This will prompt you to log in to your Inngest account, then generate types for every event in your account (plus public events) inside the api/src/__generated__/ folder.

Serve functions

RedwoodJS Serverless Functions are created in the api/src/functions/ directory. In order to keep our dependencies clean, this means we'll bundle all Inngest functions in to `api/src/inngest/.

First, let's create our handler function. This is the entry point for all Inngest functions, and will be called by Inngest when an event is triggered.

ts
// api/src/functions/inngest.ts
import { serve } from 'inngest/redwood'
export const handler = serve('My RedwoodJS App', [])

Great! We should now be able to run our dev server using yarn rw dev and see our local SDK UI at http://localhost:8910/inngest.

Some RedwoodJS configurations require that functions are accessed via /.redwood/functions/functionName in dev. If you want to follow this pattern, you can provide a servePath argument to the serve function:

ts
export const handler = serve('My RedwoodJS App', [], {
servePath: '/.redwood/functions/inngest',
})

Write functions

Now that we have our handler, let's create our first function. We'll use a simple helloWorld function.

ts
// api/src/inngest/helloWorld.ts
import { createFunction } from 'inngest'
export default createFunction('Hello World', 'demo/event.sent', () => {
return {
message: `Hello, World!`,
}
})

This function will be triggered when an event with the demo/event.sent type is sent to Inngest. It will return a message property with the value Hello, World!.

Let's add this to our handler:

ts
import { serve } from 'inngest/redwood'
import helloWorld from 'src/inngest/helloWorld'
export const handler = serve('My RedwoodJS App', [helloWorld])

Now, when we run our dev server, we should see our function listed in the Inngest UI.

For more information on writing functions, see the Writing Functions section of the Inngest docs.

Register functions

When you deploy your application, Inngest needs to know where your applicaiton is running so it can call your functions. You can "register" your app in a couple of ways:

Registering automatically

Use one of our officially supported integrations which will automatically notify Inngest whenever you've deployed updated functions:

Registering manually

If you're deploying your appliction to another platform, you can register your app via the Inngest UI or via our API with a curl request.