This example repo demonstrates how one might build our their background jobs along side a Next.js API backend. It could be any backend in any language, but this uses Next since it's fairly simple to install and understand.
👋 Have a question or suggestion? Join our Discord!
Start the Next.js app in dev mode and the Inngest dev server (install instructions):
yarn dev
inngest dev
Check out .env.example
for direction for your own .env
files. See the Next.js docs for more information.
To set environment variables for any Inngest functions prefix them (e.g. TWILIO_AUTH_TOKEN=123... inngest dev
) or set them via export
.
The demo app is a basic Next.js form view which when submitted, sends event(s) in batch to Inngest and runs the "Send SMS Dispatch" function. For reference, these are direct links to the code:
dispatch.js
- Sending an event to Inngest and Inngest DevServer during development via a Next.js API endpoints (the form receiver).index.ts
- Handling the event and sending an SMS via the Twilio API.
If you want to, create a new function by running inngest init
in the functions
directory.
- Inngest dev server support for
.env
files is in development (inngest-cli#93). If you want to use environment variables useexport VAR=val
before you runinngest dev
orrun