# Setting up your Inngest app
Source: https://www.inngest.com/docs/learn/serving-inngest-functions

description = `Serve the Inngest API as an HTTP endpoint in your application.`
hidePageSidebar = true;

With Inngest, you define functions or workflows using the SDK and deploy them to whatever platform or cloud provider you want including including serverless and container runtimes.

For Inngest to remotely execute your functions, you will need to set up a connection between your app and Inngest. This can be done in one of two ways:

<CardGroup>
  <Card title="serve()" href="#serving-inngest-functions">
    <p className="my-4">Serve your Inngest functions by creating an HTTP endpoint in your application.</p>

    <p className="my-2">**Ideal for**:</p>
    <ul className="list-disc list-inside">
      <li>Serverless platforms like Vercel, Lambda, etc.</li>
      <li>Adding Inngest to an existing API.</li>
      <li>Zero changes to your CI/CD pipeline</li>
    </ul>
  </Card>
  <Card title="connect()" href="/docs/setup/connect">
    <p className="my-4">Connect to Inngest's servers using out-bound WebSocket connection.</p>

    <p className="my-2">**Ideal for**:</p>
    <ul className="list-disc list-inside">
      <li>Container runtimes (Kubernetes, Docker, etc.)</li>
      <li>Latency sensitive applications</li>
      <li>Horizontal scaling with workers</li>
    </ul>
  </Card>
</CardGroup>

Inngest functions are portable, so you can migrate between `serve()` and `connect()` as well as cloud providers.

## Serving Inngest functions

<GuideSelector
  options={[
    { key: "typescript", title: "TypeScript" },
    { key: "go", title: "Go" },
    { key: "python", title: "Python" },
  ]}
>

<GuideSection show="typescript">

Inngest provides a `serve()` handler which adds an API endpoint to your router. You expose your functions to Inngest through this HTTP endpoint. To make automated deploys much easier, **the endpoint needs to be defined at `/api/inngest`** (though you can [change the API path](/docs/reference/serve#serve-client-functions-options)).

```ts {{ title: "./api/inngest.ts" }}
// All serve handlers have the same arguments:
serve({
  client: inngest, // a client created with new Inngest()
  functions: [fnA, fnB], // an array of Inngest functions to serve, created with inngest.createFunction()
  /* Optional extra configuration */
});
```

## Supported frameworks and platforms

<div className="grid md:grid-cols-3">

<Col>
* [Astro](#framework-astro)
* [AWS Lambda](#framework-aws-lambda)
* [Bun](#bun-serve)
* [Cloudflare Pages](#framework-cloudflare-pages-functions)
* [Cloudflare Workers](#framework-cloudflare-workers)
* [DigitalOcean Functions](#framework-digital-ocean-functions)
* [ElysiaJS](#framework-elysia-js)
* [Express](#framework-express)
</Col>
<Col>
* [Fastify](#framework-fastify)
* [Fresh (Deno)](#framework-fresh-deno)
* [Google Cloud Run Functions](#framework-google-cloud-run-functions)
* [Firebase Cloud functions](#framework-firebase-cloud-functions)
* [H3](#framework-h3)
* [Hono](#framework-hono)
* [Koa](#framework-koa)
* [NestJS](#framework-nest-js)
</Col>
<Col>
* [Next.js](#framework-next-js)
* [Nitro](#framework-nitro)
* [Nuxt](#framework-nuxt)
* [Redwood](#framework-redwood)
* [Remix](#framework-remix)
* [Supabase Edge Functions](#framework-supabase-edge-functions)
* [SvelteKit](#framework-svelte-kit)
* [Tanstack Start](#framework-tanstack-start)

</Col>

</div>

You can also create a custom serve handler for any framework or platform not listed here - [read more here](#custom-frameworks).

<Callout variant="info">
  Want us to add support for another framework? Open an issue on [GitHub](https://github.com/inngest/website) or tell us about it on our [Discord](/discord).
</Callout>

### Framework: Astro <VersionBadge version="v3.8.0+" />

Add the following to `./src/pages/api/inngest.ts`:

<CodeGroup>
```ts {{ title: "v3" }}
{ GET, POST, PUT } = serve({
  client: inngest,
  functions,
});
```
</CodeGroup>

See the [Astro example](https://github.com/inngest/inngest-js/tree/main/examples/framework-astro) for more information.

### Framework: AWS Lambda <VersionBadge version="v1.5.0+" />

We recommend using [Lambda function URLs](https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html) to trigger your functions, as these require no other configuration or cost.

Alternatively, you can use an API Gateway to route requests to your Lambda. The handler supports [API Gateway V1](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html) and [API Gateway V2](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html). If you are running API Gateway behind a proxy or have some other configuration, you may have to specify the `serveHost` and `servePath` options when calling `serve()` to ensure Inngest knows the URL where you are serving your functions. See [Configuring the API path](/docs/reference/serve#serve-client-functions-options) for more details.

<CodeGroup>
```ts {{ title: "v3" }}
// Your own function

handler = serve({
  client: inngest,
  functions: [fnA],
});
```
```ts {{ title: "v2" }}
// Your own function

handler = serve(inngest, [fnA]);
```
</CodeGroup>

### Bun.serve()

You can use the `inngest/bun` handler with `Bun.serve()` for a lightweight
Inngest server:

```ts {{ title: "index.ts" }}
Bun.serve({
  port: 3000,
  routes: {
    // ...other routes...
    "/api/inngest": serve({ client: inngest, functions }),
  },
});
```

See the [Bun example](https://github.com/inngest/inngest-js/tree/main/examples/bun) for more information.

### Framework: Cloudflare Pages Functions

You can import the Inngest API server when using <a href="https://developers.cloudflare.com/pages/platform/functions/" target="_blank" rel="nofollow">Cloudflare pages functions</a>  within `/functions/api/inngest.js`:

<CodeGroup>
```ts {{ title: "v3" }}
// Your own function

onRequest = serve({
  client: inngest,
  functions: [fnA],
});
```
```ts {{ title: "v2" }}
// Your own function

onRequest = serve({
  client: inngest,
  functions: [fnA],
});
```
</CodeGroup>

### Framework: Cloudflare Workers <VersionBadge version="v3.19.15+" />

You can export `"inngest/cloudflare"`'s `serve()` as your Cloudflare Worker:

<CodeGroup>
```ts
export default {
  fetch: serve({
    client: inngest,
    functions: [fnA],
    // We suggest explicitly defining the path to serve Inngest functions
    servePath: "/api/inngest",
  }),
};
```
</CodeGroup>

<Tip>
  To automatically pass environment variables defined with Wrangler to Inngest function handlers, use the [Cloudflare Workers bindings middleware](/docs/examples/middleware/cloudflare-workers-environment-variables).
</Tip>

#### Local development with Wrangler

When developing locally with Wrangler and the `--remote` flag, your code is
deployed and run remotely. To use this with a local Inngest Dev Server, you must
use a tool such as [ngrok](https://ngrok.com/) or
[localtunnel](https://theboroer.github.io/localtunnel-www/) to allow access to
the Dev Server from the internet.

```sh
ngrok http 8288
```

```toml {{ title: "wrangler.toml" }}
[vars]