> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trysignal.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Initialization

> Install and set up @signal-js/node with Node.js or Express

# Node — Initialization

Install **@signal-js/node** and create one client with `createSignalNode()`. Use it in plain Node.js `http`/`https` servers or in Express. Reuse the same client across all requests.

## Installation

```bash theme={null}
npm install @signal-js/node
```

## Using with Node.js

Create the client at startup and a helper to read tracing headers from `http.IncomingMessage`:

```typescript theme={null}
import http from 'http';
import { createSignalNode } from '@signal-js/node';

const signal = createSignalNode({
  apiKey: process.env.SIGNAL_API_KEY!,
  projectId: process.env.SIGNAL_PROJECT_ID!,
  // endpoint is optional (defaults to https://api.trysignal.ai/)
});

function getSessionInfo(req: http.IncomingMessage) {
  const headers = req.headers;
  return {
    sessionId: headers['x-signal-session-id'] as string | undefined,
    windowId: headers['x-signal-window-id'] as string | undefined,
    distinctId: headers['x-signal-distinct-id'] as string | undefined,
  };
}

const server = http.createServer(async (req, res) => {
  const { sessionId, windowId, distinctId } = getSessionInfo(req);
  // Use signal.capture(), signal.identify(), etc. with sessionId, windowId, distinctId
});

server.listen(3000);
```

## Using with Express

Same client; read headers from `req.headers`:

```typescript theme={null}
import express from 'express';
import { createSignalNode } from '@signal-js/node';

const app = express();
app.use(express.json());

const signal = createSignalNode({
  apiKey: process.env.SIGNAL_API_KEY!,
  projectId: process.env.SIGNAL_PROJECT_ID!,
  // endpoint is optional (defaults to https://api.trysignal.ai/)
});

function getSessionInfo(req: express.Request) {
  return {
    sessionId: req.headers['x-signal-session-id'] as string | undefined,
    windowId: req.headers['x-signal-window-id'] as string | undefined,
    distinctId: req.headers['x-signal-distinct-id'] as string | undefined,
  };
}

// Use signal and getSessionInfo in routes
```

Create one `createSignalNode()` instance per process and reuse it. For session correlation, the client must send tracing headers; see [Vue](/docs/integrations/vue/configuration) or [React](/docs/integrations/react/configuration) for `addTracingHeaders`.

## Next steps

* [Capture](/docs/integrations/node/capture) — Track events
* [Identify](/docs/integrations/node/identify) — Identify users
* [Configuration](/docs/integrations/node/configuration) — createSignalNode options
