Getting Started

Connect to TheLoopChat and send your first message in a few minutes — no infrastructure to run.

1. Create an account

Sign up at app.theloop.chat and register an app. Your app's dashboard shows:

  • Your API key (lck_…) — safe to ship in client code.
  • Your API secret (lcs_…) — shown once. Never ship it in a client bundle; it belongs on your backend only.
  • Your app's connection endpoint, used as baseUrl below.

2. Install the SDK

npm install @loopchat/core

@loopchat/core is the framework-agnostic TypeScript client. Framework-specific packages wrap it:

Package Use it for Docs
@loopchat/react Hooks + a styled default chat UI JS SDK — React
@loopchat/react-native React Native components + push helpers JS SDK — React Native
loopchat_flutter Dart client + Flutter chat widgets Flutter SDK

The rest of this guide uses @loopchat/core directly — the same concepts apply everywhere.

3. Connect and send your first message

import { LoopChatClient } from '@loopchat/core';

// baseUrl is the endpoint shown in your app's dashboard
const client = new LoopChatClient('lck_yourApiKey', { baseUrl: 'YOUR_APP_BASE_URL' });

// Token comes from YOUR backend in production (see below).
// client.devToken('user-id') works for apps with dev mode enabled — useful while you're testing.
const token = client.devToken('ada');
await client.connectUser({ id: 'ada', name: 'Ada' }, token);

const channel = client.channel('messaging', 'general');
await channel.watch();

channel.on('message.new', (event) => {
  console.log(event.message.text);
});

await channel.sendMessage({ text: 'hello!' });

That's the whole integration: connect a user, watch a channel, listen for events, send a message. See JS SDK — Core for the full client API.

4. Production tokens

Dev tokens (client.devToken(...)) only work for apps with dev mode enabled, and they're not safe for production — anyone can mint one for any user ID. In production, mint user tokens on your backend with @loopchat/node's createToken, using your app's api_secret:

import { LoopChatServerClient } from '@loopchat/node';

const server = new LoopChatServerClient(apiKey, apiSecret);
const token = server.createToken('ada'); // send this to the client over your own auth'd API

Pass that token to client.connectUser(user, token) on the client. The api_secret never leaves your backend.

Where to go next