Workflows
Inngest is an workflow orchestration platform already used by 10,000 Next.js developers, including Resend.
Whether you're building AI workflows, background jobs, or feature-specific workflows (e.g., email campaigns), Inngest has you covered with its low-latency workflow engine, which handles over 100 million daily executions.
All this while benefiting from Vercel’s platform:
app/ directory and run them locally with our Dev Server.In this guide, you'll learn how to connect a Vercel project to Inngest and set up Inngest in your Next.js application. If you don't already have a project to connect to, you can create one. Refer to "Automatic Installation" in the Next.js documentation for instructions.
Start by connecting to an existing Vercel project.
Run npm install inngest to install Inngest into your Next.js project.
In this step, you will write your first background serverless function. This function will be triggered whenever a specific event occurs (in our case, it will be test/hello.world). Then, it will sleep for a second and return a "Hello, World!".
Creating an Inngest client
First, we will create our Inngest client, which enables us to define Inngest Functions and trigger them by sending events.
Let's create a new src/inngest/functions.ts file with its Inngest client:
import { Inngest } from "inngest";
// Create a client to send and receive eventsexport const inngest = new Inngest({ id: "my-app" });Writing our first Inngest Function
Let's now write our hello-world function that will wait for one minute before returning "Hello world!".
In src/inngest/functions.ts, let's add:
export const helloWorld = inngest.createFunction( { id: "hello-world" }, { event: "test/hello.world" }, async ({ event, step }) => { await step.sleep("wait-a-moment", "1s"); return { message: `Hello ${event.data.email}!` }; },);When an event gets trigger from your application or the Inngest Dashboard, Inngest send an HTTP request to your application to run the matching Inngest Function.
To enable that, you will create a Next.js API Route at /api/inngest in app/api/inngest/route.ts:
import { serve } from "inngest/next";import { inngest, helloWorld } from "@inngest/functions";
export const { GET, POST, PUT } = serve({ client: inngest, functions: [ helloWorld, // <-- This is where you'll always add all your functions ],});
Your Next.js application is now ready! Let's start the Next.js application and the Inngest Dev Server to trigger our first Inngest Function run.
Similarly to Next.js, Inngest provides a local DevServer, enabling you to benefit from all Inngest features locally, as well as a fully featured debug UI (think of Chrome DevTools for background jobs).
You can start the Inngest DevServer by running the following command in a new terminal, alongside your Next.js app:
npx inngest-cli@latest devExecute the following command to run your application locally and make your Inngest Functions available to the Inngest DevServer:
npm run devNavigate to http://127.0.0.1:8288/functions and click "Invoke" on the hello-world function.
You'll be redirected to the Runs view, where the progress of your hello-world Inngest Function run will be displayed live.
By clicking on the hello-world run, you will see the progress of each step.
Deploying to Vercel
Once your project is ready, push your commit to deploy it to Vercel. The Inngest integration will automatically link your Vercel project by setting up the required environment variables.
If you are facing a syncing issue, consider disabling the Deployment Protection by following this guide.
Learn more about Inngest's concepts
Installation
Follow our Getting Started Next.js guide for a local-first setup experience.
To connect an existing or new Vercel project with Inngest, click “Connect Account” at the top right of this page, sign in, or sign up for your Inngest Account and select the Vercel projects to connect.
Make sure to follow this guide if your Vercel project has Deployment Protection enabled.
You are now all set; your Vercel projects are now connected to your Inngest Apps with Preview Environments support!
Links
Explore the following guides to learn more about Inngest's features: