### Install Go SDK Source: https://www.inngest.com/docs/sdk/overview Install the Inngest SDK for Go projects using the go get command. ```shell go get github.com/inngest/inngestgo ``` -------------------------------- ### Install Inngest CLI and run Dev Server Source: https://www.inngest.com/docs/reference/python/overview/quick-start Install the Inngest CLI using the provided script and then start the Inngest Dev Server, pointing it to your local Inngest endpoint. ```bash # Install the CLI - follow the steps to complete install: curl -sSfL https://cli.inngest.com/install.sh | sh # Run the dev server inngest dev -u http://localhost:8000/api/inngest ``` -------------------------------- ### Go HTTP Server for Inngest Functions Source: https://www.inngest.com/docs/learn/serving-inngest-functions Example of setting up a Go HTTP server to serve Inngest functions. This demonstrates client creation, function definition, and starting the HTTP listener. ```go package main import ( "context" "fmt" "net/http" "time" "github.com/inngest/inngestgo" "github.com/inngest/inngestgo/step" ) func main() { client, err := inngestgo.NewClient(inngestgo.ClientOpts{ AppID: "core", }) if err != nil { panic(err) } _, err = inngestgo.CreateFunction( client, inngestgo.FunctionOpts{ ID: "account-created", Name: "Account creation flow", }, // Run on every api/account.created event. inngestgo.EventTrigger("api/account.created", nil), AccountCreated, ) if err != nil { panic(err) } http.ListenAndServe(":8080", client.Serve()) } ``` -------------------------------- ### Install and Run Inngest Dev Server Source: https://www.inngest.com/docs/getting-started/nextjs-quick-start Install the Inngest CLI and start the local development server. This server allows real-time event sending, function triggering, and run inspection. ```bash curl -sSfL https://cli.inngest.com/install.sh | sh inngest dev ``` ```bash npx inngest-cli@latest dev ``` -------------------------------- ### Install Inngest CLI Source: https://www.inngest.com/docs/dev-server Install the Inngest CLI to use the dev server. Follow the on-screen instructions to complete the installation. ```bash # Install the CLI - follow the steps to complete install: curl -sSfL https://cli.inngest.com/install.sh | sh ``` -------------------------------- ### Installation Methods Source: https://www.inngest.com/docs/cli Various methods to install the Inngest CLI on your system. ```APIDOC ## Installation ### Using npx ```bash npx inngest-cli@latest ``` ### Using Homebrew ```bash brew install inngest/tap/inngest ``` ### Using curl script ```bash curl -sfL https://cli.inngest.com/install.sh | sh ``` ``` -------------------------------- ### Install Inngest CLI and Run Dev Server Source: https://www.inngest.com/docs/faq Use the bash installer to install the Inngest CLI from GitHub if you encounter issues with `npx` installations that disable npm install scripts. Then, run the dev server with a specified Inngest function URL. ```sh # Install the CLI - follow the steps to complete install: curl -sSfL https://cli.inngest.com/install.sh | sh # Run the dev server inngest dev -u http://localhost:4321/api/inngest ``` -------------------------------- ### Start Inngest Server with Shell Source: https://www.inngest.com/docs/self-hosting Start the Inngest server from the command line using the 'inngest start' command with event and signing keys. ```plaintext inngest start --event-key abcd --signing-key 1234 ``` -------------------------------- ### Inngest Start Command Help Source: https://www.inngest.com/docs/self-hosting Displays help information for the `inngest start` command, outlining available options for running Inngest as a single-node service. ```bash $ inngest start --help NAME: inngest start - [Beta] Run Inngest as a single-node service. USAGE: inngest start [options] DESCRIPTION: Example: inngest start OPTIONS: --config string Path to an Inngest configuration file --event-key string [ --event-key string ] Event key(s) that will be used by apps to send events to the server. --help, -h show help --host string Inngest server hostname --port string, -p string Inngest server port (default: "8288") --sdk-url string, -u string [ --sdk-url string, -u string ] App serve URLs to sync (ex. http://localhost:3000/api/inngest) --signing-key string Signing key used to sign and validate data between the server and apps. Must be hex string with even number of chars Advanced --connect-gateway-port int Port to expose connect gateway endpoint (default: 8289) --no-ui Disable the web UI and GraphQL API endpoint (default: false) --poll-interval int Interval in seconds between polling for updates to apps (default: 0) --queue-workers int Number of executor workers to execute steps from the queue (default: 100) --retry-interval int Retry interval in seconds for linear backoff when retrying functions - must be 1 or above (default: 0) --tick int The interval (in milliseconds) at which the executor polls the queue (default: 150) Persistence --postgres-conn-max-idle-time int Sets the maximum amount of time, in minutes, a PostgreSQL connection may be idle. (default: 5) --postgres-conn-max-lifetime int Sets the maximum amount of time, in minutes, a PostgreSQL connection may be reused. (default: 30) --postgres-max-idle-conns int Sets the maximum number of idle database connections in the PostgreSQL connection pool. (default: 10) --postgres-max-open-conns int Sets the maximum number of open database connections allowed in the PostgreSQL connection pool. (default: 100) --postgres-uri string PostgreSQL database URI for configuration and history persistence. Defaults to SQLite database. --redis-uri string Redis server URI for external queue and run state. Defaults to self-contained, in-memory Redis server with periodic snapshot backups. --sqlite-dir string Directory for where to write SQLite database. GLOBAL OPTIONS: --json Output logs as JSON. Set to true if stdout is not a TTY. (default: false) --verbose Enable verbose logging. (default: false) --log-level string, -l string Set the log level. One of: trace, debug, info, warn, error. (default: "info") ``` -------------------------------- ### Serve Inngest Functions with Tanstack Start Source: https://www.inngest.com/docs/learn/serving-inngest-functions Set up Inngest serving for Tanstack Start by defining server handlers for GET, POST, and PUT requests in your route file. ```typescript import { createFileRoute } from "@tanstack/react-router"; import { serve } from "inngest/edge"; import { inngest, functions } from "../../inngest"; const handler = serve({ client: inngest, functions }); export const Route = createFileRoute("/api/inngest")({ server: { handlers: { GET: async ({ request }) => handler(request), POST: async ({ request }) => handler(request), PUT: async ({ request }) => handler(request), }, }, }); ``` -------------------------------- ### Install Inngest CLI using curl Source: https://www.inngest.com/docs/cli Install the Inngest CLI by downloading and executing the install script. ```bash curl -sfL https://cli.inngest.com/install.sh | sh ``` -------------------------------- ### Install Inngest CLI Source: https://www.inngest.com/docs/guides/development-with-docker Install the Inngest CLI using a curl command to pipe the installation script to sh. Follow the on-screen prompts to complete the installation. ```bash curl -sSfL https://cli.inngest.com/install.sh | sh ``` -------------------------------- ### Install Workflow Kit with npm Source: https://www.inngest.com/docs/reference/workflow-kit Install the Workflow Kit and Inngest SDK using npm. Ensure your Inngest application is set up. ```shell npm install @inngest/workflow-kit inngest ``` -------------------------------- ### Install Python SDK Source: https://www.inngest.com/docs/sdk/overview Install the Inngest SDK for Python projects using pip. ```shell pip install inngest ``` -------------------------------- ### Install Inngest CLI using Homebrew Source: https://www.inngest.com/docs/cli Install the Inngest CLI using Homebrew by adding the Inngest tap. ```bash brew install inngest/tap/inngest ``` -------------------------------- ### Install Workflow Kit with pnpm Source: https://www.inngest.com/docs/reference/workflow-kit Install the Workflow Kit and Inngest SDK using pnpm. Ensure your Inngest application is set up. ```shell pnpm add @inngest/workflow-kit inngest ``` -------------------------------- ### Example Usage Source: https://www.inngest.com/docs/reference/functions/create An example of how to use `createFunction` with an event trigger. ```APIDOC import { inngest } from "./client"; export default inngest.createFunction( { id: "import-product-images", triggers: { event: "shop/product.imported" }, }, async ({ event, step, runId }) => { // Your function code } ); ``` -------------------------------- ### Install Netlify Plugin Source: https://www.inngest.com/docs/deploy/netlify Install the Netlify plugin as a development dependency for your project. ```sh npm install --save-dev netlify-plugin-inngest ``` ```sh yarn add --dev netlify-plugin-inngest ``` -------------------------------- ### Install Inngest SDK with bun Source: https://www.inngest.com/docs/getting-started/astro-quick-start Use this command to install the Inngest SDK in your project's root directory using bun. ```shell bun add inngest ``` -------------------------------- ### Install Workflow Kit with yarn Source: https://www.inngest.com/docs/reference/workflow-kit Install the Workflow Kit and Inngest SDK using yarn. Ensure your Inngest application is set up. ```shell yarn add @inngest/workflow-kit inngest ``` -------------------------------- ### Install Inngest SDK Source: https://www.inngest.com/docs/getting-started/tanstack-start-quick-start Install the Inngest SDK for your project using npm, yarn, pnpm, or bun. ```shell npm install inngest ``` ```shell yarn add inngest ``` ```shell pnpm add inngest ``` ```shell bun add inngest ``` -------------------------------- ### Install @inngest/test with Bun Source: https://www.inngest.com/docs/reference/typescript/v4/testing Install the @inngest/test package as a development dependency using Bun. ```shell bun add -d @inngest/test ``` -------------------------------- ### Install Inngest CLI with npm Source: https://www.inngest.com/docs/self-hosting Install the Inngest CLI globally using npm for command-line access. ```plaintext npm install -g inngest-cli ``` -------------------------------- ### Install Inngest SDK with pnpm Source: https://www.inngest.com/docs/getting-started/astro-quick-start Use this command to install the Inngest SDK in your project's root directory using pnpm. ```shell pnpm add inngest ``` -------------------------------- ### Install Inngest SDK with yarn Source: https://www.inngest.com/docs/getting-started/astro-quick-start Use this command to install the Inngest SDK in your project's root directory using yarn. ```shell yarn add inngest ``` -------------------------------- ### Setup Source: https://www.inngest.com/docs/reference/typescript/v4/functions/metadata Add `metadataMiddleware()` to your Inngest client to make `step.metadata()` available. ```APIDOC import { Inngest } from "inngest" import { metadataMiddleware } from "inngest/experimental" const inngest = new Inngest({ id: "my-app", middleware: [metadataMiddleware()] }); ``` -------------------------------- ### Configure `timeouts.start` in Go Source: https://www.inngest.com/docs/features/inngest-functions/cancellation/cancel-on-timeouts Use `timeouts.start` to cancel runs that remain queued for too long before starting. This example cancels if the run takes over 10 seconds to start. ```go import ( "context" "time" "github.com/inngest/inngestgo" "github.com/inngest/inngestgo/step" ) func loadInngestFnWithStartTimeout(client inngestgo.Client) (inngestgo.ServableFunction, error) { return inngestgo.CreateFunction( client, inngestgo.FunctionOpts{ Name: "A function", Timeouts: &inngestgo.ConfigTimeouts{ // If the run takes longer than 10s to start, cancel the run. Start: inngestgo.Ptr(10 * time.Second), }, }, inngestgo.EventTrigger("tasks/reminder.created", nil), func(ctx context.Context, input inngestgo.Input[map[string]any]) (any, error) { return step.Run(ctx, "send-reminder", func(ctx context.Context) (bool, error) { // ... return false, nil }) }, ) } ``` -------------------------------- ### Configure `timeouts.start` in TypeScript Source: https://www.inngest.com/docs/features/inngest-functions/cancellation/cancel-on-timeouts Use `timeouts.start` to cancel runs that remain queued for too long before starting. This example cancels if the run takes over 10 seconds to start. ```typescript const scheduleReminder = inngest.createFunction( { id: "schedule-reminder", timeouts: { // If the run takes longer than 10s to start, cancel the run. start: "10s", }, triggers: { event: "tasks/reminder.created" }, }, async ({ event, step }) => { await step.run('send-reminder-push', async () => { await pushNotificationService.push(event.data.reminder) }) } // ... ); ``` -------------------------------- ### Authentication Setup Source: https://www.inngest.com/docs/cli Instructions on how to set up authentication for the Inngest CLI using API keys. ```APIDOC ## Authentication Set your API key to start inspecting runs: ```bash export INNGEST_API_KEY=sk-inn-api-... ``` Auth precedence: 1. `--api-key` flag (explicit override) 2. `INNGEST_API_KEY` environment variable 3. `INNGEST_SIGNING_KEY` environment variable (fallback) 4. Dev server: no auth required ``` -------------------------------- ### Minimal Inngest Go App Structure Source: https://www.inngest.com/docs/reference/go/migrations/v0.7-to-v0.8 Illustrates the basic setup of an Inngest application using the Go SDK, including client initialization and function creation. ```go import ( "context" "net/http" "github.com/inngest/inngestgo" ) func HighLevel() { client, err := inngestgo.NewClient(inngestgo.ClientOpts{AppID: "my-app"}) if err != nil { panic(err) } _, err = inngestgo.CreateFunction( client, inngestgo.FunctionOpts{ID: "my-fn"}, inngestgo.EventTrigger("my-event", nil), func( ctx context.Context, input inngestgo.Input[inngestgo.GenericEvent[any, any]], ) (any, error) { return "Hello, world!", nil }, ) if err != nil { panic(err) } _ = http.ListenAndServe(":8080", client.Serve()) } ``` -------------------------------- ### Inngest Dev Server Output Source: https://www.inngest.com/docs/getting-started/tanstack-start-quick-start Example output when starting the Inngest Dev Server. It indicates the server is online and scanning for serve handlers. ```js $ inngest dev 12:33PM INF executor > service starting 12:33PM INF runner > starting event stream backend=redis 12:33PM INF executor > subscribing to function queue 12:33PM INF runner > service starting 12:33PM INF runner > subscribing to events topic=events 12:33PM INF no shard finder; skipping shard claiming 12:33PM INF devserver > service starting 12:33PM INF devserver > autodiscovering locally hosted SDKs 12:33PM INF api > starting server addr=0.0.0.0:8288 Inngest dev server online at 0.0.0.0:8288, visible at the following URLs: - http://127.0.0.1:8288 (http://localhost:8288) Scanning for available serve handlers. To disable scanning run `inngest dev` with flags: --no-discovery -u ``` -------------------------------- ### Mocking Inngest Test Engine Setup Source: https://www.inngest.com/docs/reference/typescript/v4/testing Mocks can be set globally when creating an `InngestTestEngine` instance or individually for each execution. This example shows both approaches. ```typescript const t = new InngestTestEngine({ function: helloWorld, // mocks here }); t.execute({ // mocks here }); t.executeStep("my-step", { // mocks here }) ``` -------------------------------- ### Basic serve() usage Source: https://www.inngest.com/docs/reference/typescript/v4/serve An example of how to use the `serve()` handler with your Inngest client and functions. ```APIDOC ## serve(options) ### Description The `serve()` API handler is used to serve your application's functions via HTTP. This handler enables Inngest to remotely and securely read your functions' configuration and invoke your function code. ### Usage ```ts import { serve } from "inngest/next"; // or your preferred framework import { inngest } from "./client"; import { importProductImages, sendSignupEmail, summarizeText, } from "./functions"; serve({ client: inngest, functions: [sendSignupEmail, summarizeText, importProductImages], }); ``` ### Parameters #### `client` (Inngest client) - Required - Description: An Inngest client instance. #### `functions` (InngestFunctions[]) - Required - Description: An array of Inngest functions defined using `inngest.createFunction()`. #### `serveOrigin` (string) - Optional - Description: The domain host of your application, including protocol (e.g., `https://myapp.com`). This may be required when using platforms like AWS Lambda or a reverse proxy. See also `INNGEST_SERVE_ORIGIN`. #### `servePath` (string) - Optional - Description: The path where your serve handler is hosted. The SDK attempts to infer this via HTTP headers at runtime. We recommend `/api/inngest`. See also `INNGEST_SERVE_PATH`. #### `streaming` (boolean) - Optional - Description: Enables streaming responses back to Inngest, which can enable maximum serverless function timeouts. See reference for more information. ### Callout Options like `signingKey`, `signingKeyFallback`, `logger`, `baseUrl`, and `fetch` are configured on the Inngest client, not on `serve()`. We always recommend setting the `INNGEST_SIGNING_KEY` environment variable over using the `signingKey` option directly. As with any secret, it's not a good practice to hard-code the signing key in your codebase. ``` -------------------------------- ### Inngest Dev Server Output Source: https://www.inngest.com/docs/getting-started/astro-quick-start This is an example of the output you should see when the Inngest Dev Server starts successfully. It indicates the server is online and scanning for functions. ```bash $ inngest dev -u http://localhost:4321/api/inngest 12:33PM INF executor > service starting 12:33PM INF runner > starting event stream backend=redis 12:33PM INF executor > subscribing to function queue 12:33PM INF runner > service starting 12:33PM INF runner > subscribing to events topic=events 12:33PM INF no shard finder; skipping shard claiming 12:33PM INF devserver > service starting 12:33PM INF devserver > autodiscovering locally hosted SDKs 12:33PM INF api > starting server addr=0.0.0.0:8288 Inngest dev server online at 0.0.0.0:8288, visible at the following URLs: - http://127.0.0.1:8288 (http://localhost:8288) Scanning for available serve handlers. To disable scanning run `inngest dev` with flags: --no-discovery -u ``` -------------------------------- ### Initialize Inngest Client with NewClient Source: https://www.inngest.com/docs/reference/go/migrations/v0.7-to-v0.8 Use `inngestgo.NewClient` to create a new client instance. The `AppID` option is now required and must be provided. ```go client, err := inngestgo.NewClient(inngestgo.ClientOpts{AppID: "my-app"}) ``` -------------------------------- ### Configure `timeouts.finish` in Go Source: https://www.inngest.com/docs/features/inngest-functions/cancellation/cancel-on-timeouts Use `timeouts.finish` to cancel runs that execute for too long after starting. This example cancels if the run takes over 30 seconds to finish. ```go import ( "context" "time" "github.com/inngest/inngestgo" "github.com/inngest/inngestgo/step" ) func loadInngestFnWithStartAndFinishTimeout(client inngestgo.Client) (inngestgo.ServableFunction, error) { return inngestgo.CreateFunction( client, inngestgo.FunctionOpts{ Name: "A function", Timeouts: &inngestgo.ConfigTimeouts{ // If the run takes longer than 10s to start, cancel the run. Start: inngestgo.Ptr(10 * time.Second), // And if the run takes longer than 30s to finish after starting, cancel the run. Finish: inngestgo.Ptr(30 * time.Second), }, }, inngestgo.EventTrigger("tasks/reminder.createad", nil), func(ctx context.Context, input inngestgo.Input[map[string]any]) (any, error) { return step.Run(ctx, "send-reminder", func(ctx context.Context) (bool, error) { // ... return false, nil }) }, ) } ``` -------------------------------- ### Configure `timeouts.finish` in TypeScript Source: https://www.inngest.com/docs/features/inngest-functions/cancellation/cancel-on-timeouts Use `timeouts.finish` to cancel runs that execute for too long after starting. This example cancels if the run takes over 30 seconds to finish. ```typescript const scheduleReminder = inngest.createFunction( { id: "schedule-reminder", timeouts: { // If the run takes longer than 10s to start, cancel the run. start: "10s", // And if the run takes longer than 30s to finish after starting, cancel the run. finish: "30s", }, triggers: { event: "tasks/reminder.created" }, }, async ({ event, step }) => { await step.run('send-reminder-push', async () => { await pushNotificationService.push(event.data.reminder) }) } // ... ); ``` -------------------------------- ### Start Inngest Server with Keys Source: https://www.inngest.com/docs/self-hosting Start the Inngest server, providing your event and signing keys via command-line flags. These keys can also be set as environment variables. ```plaintext inngest start --event-key --signing-key ``` -------------------------------- ### Run Inngest Dev Server with npx Source: https://www.inngest.com/docs/getting-started/express-quick-start Start the Inngest Dev Server using npx, which allows you to run the CLI without global installation. You can specify the URL of your development 'serve' API endpoint. ```shell npx --ignore-scripts=false inngest-cli@latest dev # You can specify the URL of your development `serve` API endpoint npx --ignore-scripts=false inngest-cli@latest dev -u http://localhost:3000/api/inngest ``` -------------------------------- ### Serve Inngest Functions with Next.js App Router Source: https://www.inngest.com/docs/deploy/vercel This example demonstrates how to serve Inngest functions in a Next.js App Router project. It exports `GET`, `POST`, and `PUT` handlers from the `serve` function and includes `maxDuration` configuration. ```typescript import { serve } from "inngest/next"; import { client } from "../../inngest/client"; import { firstFunction, anotherFunction } from "../../inngest/functions"; // This endpoint can run for a maximum of 300 seconds export const maxDuration = 300; export const { GET, POST, PUT } = serve({ client: client, functions: [ firstFunction, anotherFunction ] }); ``` -------------------------------- ### Initialize New H3 Project Source: https://www.inngest.com/docs/getting-started/h3-quick-start Create a new directory, initialize an npm project, and install the h3 package. ```shell mkdir my-h3-app && cd my-h3-app npm init -y npm install h3 ``` -------------------------------- ### Bun Durable Endpoint for Trip Booking Source: https://www.inngest.com/docs/examples/durable-endpoints Implement a multi-step trip booking workflow using Inngest Durable Endpoints with Bun. This snippet shows the same workflow as the Next.js example but adapted for a Bun runtime environment, demonstrating flexibility across different server setups. ```typescript import { Inngest, step } from "inngest"; import { endpointAdapter } from "inngest/edge"; const inngest = new Inngest({ id: "trip-booker", endpointAdapter }); Bun.serve({ port: 3000, routes: { "/api/booking": inngest.endpoint(async (req) => { const url = new URL(req.url); const origin = url.searchParams.get("origin") || "NYC"; const destination = url.searchParams.get("destination") || "LAX"; const date = url.searchParams.get("date") || new Date().toISOString().split("T")[0]; // Step 1: Search for available flights const availability = await step.run("search-availability", async () => { const flights = await searchFlights(origin, destination, date); return { flights }; }); // Step 2: Reserve the best flight // If the seat lock times out, Inngest automatically retries this step // without re-running the search const reservation = await step.run("reserve-flight", async () => { const best = availability.flights[0]; return await reserveSeat(best.flightNumber, "14A"); }); // Step 3: Process payment const payment = await step.run("process-payment", async () => { return await chargeCard(reservation.price, reservation.pnr); }); // Step 4: Confirm the booking const confirmation = await step.run("confirm-booking", async () => { return await confirmReservation(reservation.reservationId); }); return new Response(JSON.stringify({ success: true, trip: { origin, destination, date }, reservation, payment, confirmation, })); }), }, }); ``` -------------------------------- ### Using step.run Source: https://www.inngest.com/docs/reference/python/steps/run Demonstrates how to use `step.run` to execute functions durably, with and without arguments, and how to handle keyword arguments using `functools.partial`. ```APIDOC ## step.run ### Description Turns a normal function into a durable function. Any function passed to `step.run` will be executed in a durable way, including retries and memoization. ### Arguments - `step_id` (str): Step ID. Should be unique within the function. - `handler` (Callable): A callable that has no arguments and returns a JSON serializable value. - `*handler_args`: Positional arguments for the handler. This is type-safe since we infer the types from the handler using generics. ### Request Example ```python @inngest_client.create_function( fn_id="my_function", trigger=inngest.TriggerEvent(event="app/my_function"), ) async def fn(ctx: inngest.Context) -> None: # Pass a function to step.run await ctx.step.run("my_fn", my_fn) # Args are passed after the function await ctx.step.run("my_fn_with_args", my_fn_with_args, 1, "a") # Kwargs require functools.partial await ctx.step.run( "my_fn_with_args_and_kwargs", functools.partial(my_fn_with_args_and_kwargs, 1, b="a"), ) # Defining functions like this gives you easy access to scoped variables def use_scoped_variable() -> None: print(ctx.event.data["user_id"]) await ctx.step.run("use_scoped_variable", use_scoped_variable) async def my_fn() -> None: pass async def my_fn_with_args(a: int, b: str) -> None: pass async def my_fn_with_args_and_kwargs(a: int, *, b: str) -> None: pass ``` ### Retries Each `step.run()` call has its own independent retry counter. When a step raises an exception, it will be retried according to your function's retry configuration. The retry configuration applies to each individual step, not as a shared pool across all steps in your function. For example, if your function is configured with `retries=4`, each `step.run()` will be retried up to 4 times independently (5 total attempts including the initial attempt). If you have multiple steps in your function, each step gets its own full set of retries. ``` -------------------------------- ### Define Fan-out Functions for User Signup Source: https://www.inngest.com/docs/guides/fan-out-jobs Implement two independent Inngest functions, 'send-welcome-email' and 'start-stripe-trial', both triggered by the 'app/user.signup' event. Each function uses Inngest steps to perform its specific task, ensuring parallel execution. ```go func loadSendWelcomeEmailInngestFn(client inngestgo.Client) (inngestgo.ServableFunction, error) { return inngestgo.CreateFunction( client, inngestgo.FunctionOpts{ ID: "send-welcome-email", }, inngestgo.EventTrigger("app/user.signup", nil), func(ctx context.Context, input inngestgo.Input[map[string]any]) (any, error) { _, err := step.Run(ctx, "send-email", func(ctx context.Context) (any, error) { return SendEmail(SendEmailInput{ To: input.Event.Data["user"].(map[string]interface{})["email"].(string), Subject: "welcome", }) }) return nil, err }, ) } func loadStartStripeTrialInngestFn(client inngestgo.Client) (inngestgo.ServableFunction, error) { return inngestgo.CreateFunction( client, inngestgo.FunctionOpts{ ID: "start-stripe-trial", }, inngestgo.EventTrigger("app/user.signup", nil), func(ctx context.Context, input inngestgo.Input[map[string]any]) (any, error) { customerID, err := step.Run(ctx, "create-customer", func(ctx context.Context) (any, error) { return CreateStripeAccount(&StripeCustomerParams{ Email: input.Event.Data["user"].(map[string]interface{})["email"].(string), }) }) if err != nil { return nil, err } _, err = step.Run(ctx, "create-subscription", func(ctx context.Context) (any, error) { return CreateStripeSubscription(&StripeSubscriptionParams{ Customer: customerID.(string), TrialPeriodDays: 14, }) }) return nil, err }, ) } ``` -------------------------------- ### Stream AI Inference and Translations with Durable Endpoints Source: https://www.inngest.com/docs/learn/durable-endpoints/streaming This example demonstrates streaming AI-generated text and its translation back to a client using Inngest's durable endpoints. It shows two options for streaming: `stream.push()` for SDK event callbacks and `stream.pipe()` for streaming chunks and returning collected text. Ensure you have the Anthropic SDK installed and configured. ```typescript import Anthropic from "@anthropic-ai/sdk"; import { step } from "inngest"; import { stream } from "inngest/experimental/durable-endpoints"; import { inngest } from "@/inngest"; export const GET = inngest.endpoint(async () => { // Option A: push() with an SDK event callback const text = await step.run("generate", async () => { stream.push("Generating...\n"); const client = new Anthropic(); const response = client.messages.stream({ model: "claude-sonnet-4-20250514", max_tokens: 512, messages: [{ role: "user", content: "Write a haiku about durability." }], }); response.on("text", (token) => stream.push(token)); return await response.finalText(); }); // Option B: pipe() — streams each chunk AND returns the collected text await step.run("translate", async () => { stream.push(`\nTranslating...\n`); const client = new Anthropic(); const response = client.messages.stream({ model: "claude-sonnet-4-20250514", max_tokens: 256, messages: [{ role: "user", content: `Translate to French: ${text}` }], }); return stream.pipe(async function* () { for await (const event of response) { if ( event.type === "content_block_delta" && event.delta.type === "text_delta" ) { yield event.delta.text; } } }); }); return new Response("\nDone!"); }); ``` -------------------------------- ### Setup Metadata Middleware Source: https://www.inngest.com/docs/reference/typescript/functions/metadata Add metadataMiddleware() to your Inngest client to make step.metadata() available. ```typescript import { Inngest, } from "inngest"; import { metadataMiddleware, } from "inngest/experimental"; const inngest = new Inngest({ id: "my-app", middleware: [metadataMiddleware()], }); ``` -------------------------------- ### Basic H3 Server Setup Source: https://www.inngest.com/docs/getting-started/h3-quick-start Create an index.ts file with a basic H3 server configuration. ```typescript import { createApp, createRouter, eventHandler, toNodeListener } from "h3"; import { createServer } from "node:http"; const app = createApp(); const router = createRouter(); app.use(router); createServer(toNodeListener(app)).listen(3000, () => { console.log("Server running on http://localhost:3000"); }); ``` -------------------------------- ### Install and Run Inngest CLI Dev Server Source: https://www.inngest.com/docs/local-development Install the Inngest CLI and then run the dev server, optionally specifying the serve API endpoint URL. This is the primary method for local development. ```shell curl -sSfL https://cli.inngest.com/install.sh | sh inngest dev -u http://localhost:3000/api/inngest ``` -------------------------------- ### Install ESLint Plugin Source: https://www.inngest.com/docs/sdk/eslint Install the Inngest ESLint plugin as a dev dependency. ```sh npm install -D @inngest/eslint-plugin ``` -------------------------------- ### Install envelop-plugin-inngest Source: https://www.inngest.com/docs/guides/instrumenting-graphql Install the necessary package for instrumenting GraphQL operations with Inngest. ```sh npm install envelop-plugin-inngest # or yarn add ``` -------------------------------- ### Start the Inngest Dev Server Source: https://www.inngest.com/docs/dev-server Run the Inngest dev server from your project directory. Ensure your app is configured to connect to it by setting the INGTEST_DEV environment variable. ```bash inngest dev -u http://localhost:3000/api/inngest ``` -------------------------------- ### Install @inngest/test with Deno Source: https://www.inngest.com/docs/reference/typescript/v4/testing Install the @inngest/test package as a development dependency using Deno. ```shell deno add --dev @inngest/test # or with JSR... deno add --dev jsr:@inngest/test ``` -------------------------------- ### Serve Inngest Functions with Bun.serve() Source: https://www.inngest.com/docs/learn/serving-inngest-functions Integrate Inngest with `Bun.serve()` for a lightweight Inngest server. This example sets up the Inngest handler at the `/api/inngest` route. ```typescript import { serve } from "inngest/bun"; import { functions, inngest } from "./inngest"; Bun.serve({ port: 3000, routes: { // ...other routes... "/api/inngest": serve({ client: inngest, functions }), }, }); ``` -------------------------------- ### Install @inngest/test with pnpm Source: https://www.inngest.com/docs/reference/typescript/v4/testing Install the @inngest/test package as a development dependency using pnpm. ```shell pnpm add -D @inngest/test ``` -------------------------------- ### Install @inngest/test with Yarn Source: https://www.inngest.com/docs/reference/typescript/v4/testing Install the @inngest/test package as a development dependency using Yarn. ```shell yarn add -D @inngest/test ``` -------------------------------- ### Start Inngest Server with Docker Source: https://www.inngest.com/docs/self-hosting Run the Inngest server using Docker, mapping ports and setting environment variables for event and signing keys. ```plaintext docker run -p 8288:8288 -p 8289:8289 -e INNGEST_EVENT_KEY=abcd -e INNGEST_SIGNING_KEY=1234 inngest/inngest inngest start ``` -------------------------------- ### Go HTTP App Creation Source: https://www.inngest.com/docs/apps Create an Inngest app in Go using the http package. This example initializes the Inngest client and defines a function triggered by an event. ```go package main import ( "context" "fmt" "net/http" "time" "github.com/inngest/inngestgo" "github.com/inngest/inngestgo/step" ) func main() { client, err := inngestgo.NewClient(inngestgo.ClientOpts{ AppID: "sandbox-go", }) if err != nil { panic(err) } f, err := inngestgo.CreateFunction( client, inngestgo.FunctionOpts{ ID: "account-created", Name: "Account creation flow", }, // Run on every api/account.created event. inngestgo.EventTrigger("api/account.created", nil), AccountCreated, ) if err != nil { log.Fatal(err) } http.ListenAndServe(":8080", f.Serve()) } ```