***
id: 842057a6-bbf3-4870-a3ef-e74b7440cd07
title: RELAY Realtime SDK v3
sidebar-title: Overview
position: 0
slug: /node
subtitle: >-
Node.js server SDK for real-time communication (deprecated - consider
upgrading to v4)
description: >-
RELAY Realtime SDK v3 for Node.js. Build real-time voice, video, messaging,
and chat applications. Deprecated - upgrade to v4 for the latest features.
max-toc-depth: 3
----------------
The [RELAY v4](/docs/server-sdk) is the most up-to-date version of the Realtime RELAY SDK.
Consider reading the [Upgrading to RELAY v4](/docs/server-sdk/v3/node/guides/realtime-relay-v4-vs-v3) page to understand the benefits of
[RELAY v4](/docs/server-sdk) and how to upgrade.
@signalwire/realtime-api@\~3
signalwire/signalwire-js
```bash
npm install @signalwire/realtime-api@~3
```
The SignalWire Realtime SDK v3 is a Node.js server SDK that enables real-time communication through WebSocket connections. Built on an event-driven architecture, it provides dedicated namespaces for voice, video, messaging, chat, pub/sub, and task management.
## Getting Started
```bash
npm install @signalwire/realtime-api@~3
```
For Voice, Messaging, and Task namespaces, create a RELAY Application resource in your dashboard:
1. Set a name for your application
2. Choose a reference (e.g., "support", "sales") that matches your client's topics
3. Assign [phone numbers](/docs/platform/phone-numbers#phone-number-configuration) or [SIP addresses](/docs/platform/addresses) to route calls to this application
Get your project credentials from the [SignalWire Dashboard](/docs/platform/your-signalwire-api-space):
```javascript
import { Voice } from "@signalwire/realtime-api";
const client = new Voice.Client({
project: "your-project-id",
token: "your-api-token",
topics: ["support"] // Must match your RELAY Application reference
});
```
Create a simple inbound call handler to test your setup:
```javascript
import { Voice } from "@signalwire/realtime-api";
const client = new Voice.Client({
project: "your-project-id",
token: "your-api-token",
topics: ["support"] // Must match your RELAY Application reference
});
// Answer incoming calls and play a greeting
client.on("call.received", async (call) => {
console.log("Incoming call from:", call.from);
await call.answer();
await call.playTTS({ text: "Welcome to SignalWire!" });
});
console.log("Waiting for calls...");
```
Now call the SignalWire phone number or SIP address you assigned to your RELAY Application in step 2. Your application will answer and play the greeting!
## Core Concepts
### WebSocket Event Architecture
The SDK operates on a bidirectional WebSocket connection between your application and SignalWire's servers. This enables real-time communication through a structured event system:
```mermaid
graph LR
A["SDK Client
(Your Application)"] <-->|"Method Calls
client.dial(), client.send()
roomSession.join()"| B[WebSocket
Connection] <-->|"Process & Respond"| C[SignalWire]
C -->|"Real-time Events
call.received, message.received
room.started"| B -->|"Event Data
client.on('events')"| A
```
When you call a method like `client.dial()`, the SDK sends your request over the WebSocket connection and SignalWire processes it and responds immediately. These method calls follow a request-response pattern - the returned promise resolves with the result data, such as a `Call` object containing all the details of your newly created call.
The `.on()` methods handle a different communication pattern: real-time event notifications. These are asynchronous events triggered by external actions - like when someone calls your number (`call.received`), sends you a message (`message.received`), or when something happens in a video room you're monitoring (`member.joined`). Unlike method responses, these events arrive whenever the triggering action occurs, not as a direct response to your code.
### Authentication and Access Control
All SDK clients authenticate using project credentials. Voice, Messaging, and Task namespaces also require topic subscriptions that control event routing:
```javascript
const client = new Voice.Client({
project: "your-project-id", // SignalWire project identifier
token: "your-project-token", // API token from project settings
topics: ["support", "sales"] // Required for Voice, Messaging, Task
});
```
Your `project` ID and `token` are available in the [SignalWire Dashboard](/docs/platform/your-signalwire-api-space). These authenticate your WebSocket connection and establish your access permissions.
Topics (formerly contexts) work with RELAY Application resources to route events. When you assign a phone number or a SIP address to a RELAY Application with reference "support", SignalWire routes all calls from that number or SIP address to SDK clients authenticated with the "support" topic. This creates strict access control - a client subscribed to "support" cannot receive events intended for "sales".
The routing process is straightforward: incoming calls hit a phone number or a SIP address, SignalWire checks the RELAY Application's reference, then delivers the event only to clients with matching topics. This happens automatically based on your authentication.
```javascript
// Topic-based client (receives events only for subscribed topics)
const voice = new Voice.Client({
project: "project-id",
token: "token",
topics: ["support", "sales"] // Only receive calls for these topics
});
// Non-topic client (receives all events for the project)
const video = new Video.Client({
project: "project-id",
token: "token" // No topics needed
});
```
## Available Namespaces
Make and receive calls, play audio, record, and build IVRs
Monitor video rooms, members, recordings, and streams
Publish and subscribe to real-time message channels
Build chat applications with members and messages
Distribute tasks to workers via topic routing
## Classes
The core client for establishing WebSocket connections and accessing all SDK namespaces.
## Functions
### ~~createClient~~
* `Const` **createClient**(`userOptions`): `Promise` - **Deprecated** — See [RealtimeClient](/docs/server-sdk/v3/node/reference/realtime-client) for more details.
> **Deprecated**
> You no longer need to create the client manually. You can use the product constructors, like [Video.Client](/docs/server-sdk/v3/node/reference/video/room-session), to access the same functionality.
Creates a real-time Client.
#### Parameters
| Name | Type | Description |
| :---------------------- | :------------------------------------------------------------------------ | :---------------------------------------------------------------------------------- |
| `userOptions` | `Object` | |
| `userOptions.logLevel?` | `"debug"` \| `"trace"` \| `"info"` \| `"warn"` \| `"error"` \| `"silent"` | logging level |
| `userOptions.project?` | `string` | SignalWire project id, e.g. `a10d8a9f-2166-4e82-56ff-118bc3a4840f` |
| `userOptions.token` | `string` | SignalWire project token, e.g. `PT9e5660c101cd140a1c93a0197640a369cf5f16975a0079c9` |
#### Returns
`Promise` - **Deprecated** — See [RealtimeClient](/docs/server-sdk/v3/node/reference/realtime-client) for more details.
an instance of a real-time Client.
#### Example
```typescript
const client = await createClient({
project: "",
token: "",
});
```
***
### getConfig
* `Const` **getConfig**(): `GlobalConfig`
#### Returns
`GlobalConfig`