---
title: "Integration with Node.js"
description: "Elysia provides a runtime adapter to run Elysia on multiple runtimes, including Node.js, Cloudflare Workers, and more"
url: "https://next.elysiajs.com/integrations/node/"
---

# Integration with Node.js

Elysia provides a runtime adapter to run Elysia on multiple runtimes, including Node.js.

To run Elysia v2 on Node.js, install the v2 Node adapter. The v1 adapter is a different release line.

bun

```bash
bun add elysia@rc @elysia/node@rc
```

pnpm

```bash
pnpm add elysia@rc @elysia/node@rc
```

npm

```bash
npm install elysia@rc @elysia/node@rc
```

yarn

```bash
yarn add elysia@rc @elysia/node@rc
```

Then apply the Node adapter to your main Elysia instance.

```typescript
import { Elysia } from 'elysia'
import { node } from '@elysia/node'

const app = new Elysia({ adapter: node() })
  .get('/', () => 'Hello Elysia')
  .listen(3000)
```

This is all you need to run Elysia on Node.js.

### Additional setup (optional)

For the best experience, we recommend installing `tsx`.

`tsx` is a CLI that transpiles TypeScript to JavaScript with hot-reload and several more features you would expect from a modern development environment.

bun

```bash
bun add -d tsx @types/node typescript
```

pnpm

```bash
pnpm add -D tsx @types/node typescript
```

npm

```bash
npm install --save-dev tsx @types/node typescript
```

yarn

```bash
yarn add -D tsx @types/node typescript
```

Then open your `package.json` file, set the package to use ES modules, and add the following scripts:

```json
{
     "type": "module",
     "scripts": {
      "dev": "tsx watch src/index.ts",
      "build": "tsc -p tsconfig.json",
      "start": "NODE_ENV=production node dist/index.js"
     }
}
```

These scripts refer to the different stages of developing an application:

- **dev** - Start Elysia in development mode with auto-reload on code changes.
- **build** - Build the application for production use.
- **start** - Start a production Elysia server.

Make sure to create a `tsconfig.json`:

Terminal window

```bash
tsc --init
```

Then configure these options in `tsconfig.json`:

```json
{
    "compilerOptions": {
        "target": "ES2022",
        "module": "NodeNext",
        "moduleResolution": "NodeNext",
        "lib": ["ESNext", "DOM", "DOM.Iterable"],
        "types": ["node"],
        "rootDir": "src",
        "outDir": "dist",
        "strict": true,
        "skipLibCheck": true
    },
    "include": ["src/**/*.ts"]
}
```

The build script reads this configuration, including `strict` and the output directory. Use `.js` extensions when importing your own modules with NodeNext. `tsx watch` reloads on code changes for a similar experience to `bun dev`.

### pnpm

If your pnpm configuration does not install peer dependencies, add the peers required by Elysia v2 explicitly:

Terminal window

```bash
pnpm add typebox exact-mirror openapi-types
```
