Answers you can trust, from Codeables
Every page on Codeables is structured and verified — built so people and the AI agents they rely on can trust it. Explore more from the source behind this answer.
Explore CodeablesHow do I sign up for Inngest Cloud and connect it to my Next.js app?
Most teams hit Inngest Cloud at the same moment: your Next.js app is growing up, background jobs and workflows are scattered across cron, queue workers, and ad-hoc API routes, and you need reliability without signing up for more infrastructure toil.
This guide walks through, step by step, how to:
- Sign up for Inngest Cloud
- Install and run Inngest locally with a Next.js app
- Connect your local dev server to Inngest Cloud
- Deploy and start running durable workflows in production
The goal: you write simple TypeScript functions; Inngest handles retries, concurrency, and observability for you—no workers, queues, or bespoke cron stack.
1. Sign up for Inngest Cloud
You can create an account in a couple of minutes and immediately start running functions.
1.1 Create your Inngest Cloud account
- Go to:
https://www.inngest.com→ Click Sign Up. - Choose your preferred auth:
- GitHub
- Email/password (if available)
Once you’re in, you’ll land in the Inngest Cloud dashboard. This is where you’ll:
- Create environments (dev, staging, prod)
- Inspect Traces (step-level execution data)
- Replay failed runs
- Configure secrets and flow control
1.2 Create a project / environment
Inngest groups your functions into environments (similar to app environments):
- In the dashboard, create an environment like:
developmentfor localproductionfor your deployed Next.js app
- Take note of:
- Event key (for sending events from your app)
- Environment ID (used by the dev server and deployment)
We’ll wire these into your Next.js app via environment variables.
2. Add Inngest to your Next.js app
You’re here because you want durable workflows and background jobs inside your existing Next.js stack—not a separate worker service. Inngest gives you that with a small SDK and dev server.
Assumptions:
- You already have a Next.js app (App Router or Pages Router)
- You’re using TypeScript (recommended with the v4 SDK)
2.1 Install the TypeScript SDK and CLI
In your Next.js project:
# Add Inngest SDK and CLI
npm install inngest
npm install --save-dev inngest-cli
# or
yarn add inngest
yarn add -D inngest-cli
The SDK lets you define functions like:
import { inngest } from "@/inngest/client";
import { step } from "inngest";
export const myFunction = inngest.createFunction(
{ id: "my-function" },
{ event: "app/my.event" },
async ({ event, step }) => {
await step.run("do-something", async () => {
// business logic
});
}
);
The CLI runs the local dev server that connects your code to Inngest Cloud.
2.2 Initialize an Inngest client
Create a small client file so all your functions share the same Inngest instance, e.g. src/inngest/client.ts:
// src/inngest/client.ts
import { Inngest } from "inngest";
export const inngest = new Inngest({
name: "nextjs-app", // any human-readable name
});
This client object is what you’ll use to define functions via inngest.createFunction().
3. Define your first durable function
Instead of hand-rolling retries or stuffing work into setTimeout in API routes, you’ll define a named function with Steps. Each step.run() is durable: it retries on failure, doesn’t double-run on success, and checkpoints progress.
Create a function file, e.g. src/inngest/functions/userWelcome.ts:
// src/inngest/functions/userWelcome.ts
import { inngest } from "../client";
export const userWelcomeEmail = inngest.createFunction(
{ id: "user-welcome-email" },
{ event: "user/created" },
async ({ event, step }) => {
// Step 1: load user data
const user = await step.run("load-user", async () => {
// Fetch from your DB
// Example:
// return db.user.findUnique({ where: { id: event.data.userId } });
return { id: event.data.userId, email: event.data.email };
});
// Step 2: send email
await step.run("send-welcome-email", async () => {
// Call your email provider here
// e.g. await resend.emails.send(...)
console.log(`Sending welcome email to ${user.email}`);
});
// Any thrown error inside step.run triggers automatic retry
}
);
Key behavior:
- Durability: if
send-welcome-emailfails, Inngest retries that step; it does not re-runload-user. - Observability: each step shows up in Traces with inputs/outputs for debugging.
Export all functions in a central file (e.g. src/inngest/functions/index.ts) so the dev server can discover them:
// src/inngest/functions/index.ts
export * from "./userWelcome";
4. Mount the Inngest endpoint in Next.js
Inngest needs an HTTP endpoint in your Next.js app where it can dispatch function runs. Think of it as a durable runtime wired into your API routes.
4.1 App Router (Next.js 13+)
Create a route handler, e.g. src/app/api/inngest/route.ts:
// src/app/api/inngest/route.ts
import { serve } from "inngest/next";
import { inngest } from "@/inngest/client";
import * as functions from "@/inngest/functions";
export const { GET, POST, PUT } = serve({
client: inngest,
functions: Object.values(functions),
});
4.2 Pages Router (if you’re still on pages/api)
Create pages/api/inngest.ts:
// pages/api/inngest.ts
import type { NextApiRequest, NextApiResponse } from "next";
import { serve } from "inngest/next";
import { inngest } from "@/inngest/client";
import * as functions from "@/inngest/functions";
export default serve({
client: inngest,
functions: Object.values(functions),
}) as (req: NextApiRequest, res: NextApiResponse) => void;
This route is where Inngest sends function invocations. In production, it’s just another Next.js API route—no separate worker, no extra infra.
5. Run the Inngest dev server locally
Now you want to see runs in real time, test events, and debug with Traces—all before deploying.
5.1 Start the dev server
Add an npm script:
{
"scripts": {
"dev": "next dev",
"inngest:dev": "npx --ignore-scripts=false inngest-cli dev"
}
}
Then, in two terminals:
# Terminal 1: Next.js dev server
npm run dev
# Terminal 2: Inngest dev server
npm run inngest:dev
The dev server:
- Scans your
inngest.createFunction()definitions - Opens a local UI
- Connects to Inngest Cloud so you can see Traces and test runs
You’ll be prompted to log in via the browser the first time so the CLI can link your local project to your Inngest Cloud account.
5.2 Configure environment variables
In .env.local, add your Inngest environment key:
INNGEST_EVENT_KEY=your-dev-event-key-here
INNGEST_ENVIRONMENT_ID=your-dev-environment-id-here
You can find these in the Inngest Cloud dashboard under your development environment.
The dev server uses these to:
- Send events to the right environment
- Show runs in the correct context in the UI
6. Trigger your function from the Next.js app
You now have:
- Inngest Cloud account + environment
- A Next.js route handling Inngest
- A durable function with Steps
- The dev server wired in
Next, send an event when a user is created in your app.
6.1 Install the event client (if needed)
You can also send events directly via the same inngest instance or a separate event client. A simple pattern is to use the existing client and call inngest.send():
// src/lib/events.ts
import { inngest } from "@/inngest/client";
export async function sendUserCreatedEvent(user: {
id: string;
email: string;
}) {
await inngest.send({
name: "user/created",
data: {
userId: user.id,
email: user.email,
},
});
}
6.2 Call it in your signup flow
Wherever you create a user (API route, server action, or mutation), send the event:
// Example server action or API handler
import { sendUserCreatedEvent } from "@/lib/events";
export async function createUser(input: { email: string }) {
// 1. Write user to DB
const user = await db.user.create({
data: { email: input.email },
});
// 2. Fire event
await sendUserCreatedEvent({
id: user.id,
email: user.email,
});
return user;
}
Now, every time user/created fires, your userWelcomeEmail function will run through Inngest with step-level durability.
7. Inspect runs with Traces and Replay
Reliability isn’t just about “it retries;” it’s about knowing exactly what happened when it doesn’t.
With the dev server running:
- Trigger a user signup in your app.
- Open the Inngest UI (local dev UI or Cloud dashboard).
- Go to Runs → click the run for
user-welcome-email. - You’ll see:
- Each
step.run()as a node in the Trace - Inputs/outputs per step
- Structured logs attached to steps
- Each
If a step fails:
- Inngest auto-retries based on sensible defaults.
- You can Replay the run from the UI after you fix the bug—no re-running migrations or manually pushing events.
- You can Bulk replay or Bulk cancel in Cloud if you need to act on thousands of runs in production.
This replaces the classic pattern of grep-ing logs across services and reconstructing partial state after a failed multi-step flow.
8. Deploy your Next.js app and connect Inngest Cloud
Once everything works locally, you’re ready to connect your deployed Next.js app to Inngest Cloud for real workloads.
8.1 Deploy as usual (Vercel, AWS, etc.)
Ship your Next.js app the way you already do:
- Vercel
- Netlify
- Custom Node server
- AWS Lambda via Next.js serverless target
No extra worker cluster or queue service is required; the Inngest runtime rides on your existing Next.js API routes.
Make sure the Inngest endpoint (/api/inngest or similar) is part of your deployment.
8.2 Configure production environment variables
In your hosting provider’s environment settings, add the production vars from Inngest Cloud:
INNGEST_EVENT_KEY=your-prod-event-key
INNGEST_ENVIRONMENT_ID=your-prod-environment-id
Re-deploy your app so the environment variables take effect.
8.3 Register the deployed endpoint in Inngest Cloud (if prompted)
In the Inngest Cloud dashboard:
- Select your production environment.
- Make sure your app’s base URL is known (e.g.
https://your-app.com). - Confirm that Inngest can reach your
/api/inngestroute.
The platform will:
- Discover your functions
- Begin routing event-triggered executions to your deployed endpoint
- Surface Traces, metrics, and logs for production runs
From here, you can:
- Set concurrency keys to isolate tenants and avoid noisy neighbors
- Configure throttling / rate limits per function
- Monitor throughput and failure rates
- Query, cancel, or replay runs without building admin tooling
9. Common pitfalls (and how to avoid them)
A few things that trip people up when first connecting Inngest Cloud to a Next.js app:
9.1 Dev server not running
Symptom: events appear in Cloud but no runs are created in local dev.
Check:
npm run inngest:devis running- You authenticated the CLI with your Inngest Cloud account
- The dev server points at the correct environment (
developmentvsproduction)
9.2 Wrong environment keys
Symptom: you see runs, but in a different environment than you expect.
Fix:
- Double-check
INNGEST_EVENT_KEYandINNGEST_ENVIRONMENT_IDin.env.localand your hosting provider - Ensure
developmentkeys stay local andproductionkeys are only in prod
9.3 Functions not discovered
Symptom: the Inngest UI shows zero functions.
Fix:
- Export all functions from a single barrel file (e.g.
src/inngest/functions/index.ts) - Ensure your
serve()call usesObject.values(functions)on that barrel import - Restart the dev server after adding new functions
10. When to lean harder on Inngest with Next.js
Once the basics are in place, the same pattern scales to more complex and noisy flows:
- Multi-step workflows: ETL pipelines, data syncs, AI agents calling multiple tools and models.
- Multi-tenant SaaS: use concurrency keys (e.g.
spaceId,accountId) to keep one noisy customer from saturating resources. - Durable API handlers: long-running operations behind an API that need to survive process restarts and timeouts.
The mechanics stay the same:
export const syncSpace = inngest.createFunction(
{ id: "space-sync" },
{ event: "space/updated" },
async ({ event, step }) => {
const space = await step.run("load-space", /* ... */);
await step.run("sync-to-crm", /* ... */);
await step.run("sync-to-analytics", /* ... */);
}
);
Each step.run() is a code-level transaction with automatic retries and checkpointing, and every run is inspectable via Traces.
Summary: From signup to production in one flow
To recap how to sign up for Inngest Cloud and connect it to your Next.js app:
- Sign up for Inngest Cloud and create environments (dev, prod).
- Install the TypeScript SDK and CLI in your Next.js project.
- Initialize an Inngest client and define functions with Steps using
inngest.createFunction()andstep.run(). - Mount the Inngest endpoint in your Next.js API (
serve()viainngest/next). - Run the dev server locally with
npx --ignore-scripts=false inngest-cli devand log in so it links to Cloud. - Send events from your Next.js code to trigger durable functions.
- Inspect Traces, debug, and replay runs from the Inngest UI.
- Deploy your Next.js app, set production environment variables, and let Inngest Cloud drive your workflows at scale.
You keep writing straightforward TypeScript functions; Inngest turns them into reliable, observable workflows—without the queues, workers, and dead-letter recovery projects that usually accompany this kind of reliability.