Skip to main content

Getting Started

Installing

You can install aircampi's realtime via NPM, Yarn or CDN.

NPM:

  npm install @aircampi/realtime

Yarn:

  yarn add @aircampi/realtime

CDN:

  <script src="https://cdn.jsdelivr.net/npm/@aircampi/realtime"/>

//or

<script src="https://unpkg.com/@aircampi/realtime"/>

Find the source code on GitHub.

Initializing

There are 2 way to initialize new client.

Using createRealtimeClient():


import { createRealtimeClient } from '@aircampi/realtime'

// Create a Realtime client for interacting with your realtime stack

const rt = createRealtimeClient({
domain: '<YOUR_DOMAIN>',
client_id: '<YOUR_CLIENT_ID>'
})

Using RealtimeClient object


import { RealtimeClient } from '@aircampi/realtime';

const rt = new RealtimeClient({
domain: '<YOUR_DOMAIN>',
client_id: '<YOUR_CLIENT_ID>'
});

//if you do this, you'll need to get list of channels

try {
await rt.getChannels();
} catch (error) {
if (error.error !== 'login_required') {
throw error;
}
}