All documentation
Getting Started

Complete Node and Python Realtime Example

A compact end-to-end example showing two trusted backends sharing one dynamic channel through PulseGrid 0.2.0.

Multi-language

Overview

This example demonstrates the main PulseGrid flow without creating separate documentation pages for every helper. Both applications use the same project. The first one ensures a channel exists, each backend creates its own client token, and both connect to the same room. An event published by either side can be received by all connected clients.

Setup

1. Configure the same PulseGrid project keys in both applications. 2. Ensure the desired channel exists from one trusted backend. 3. Create one client token per realtime identity. 4. Connect Node and Python. 5. Send a message or custom event. 6. Check history and presence. 7. Observe heartbeat pongs as connection maintenance, not repeated user actions.

Code example

Complete Node and Python Realtime Example
Node.js
import { createPulseGrid } from "pulsegrid";
const pg = createPulseGrid();

const existing = await pg.channels.all();
let room = existing.find(c => c.slug === "live-operations");
if (!room) {
  const created = await pg.channels.create({ name: "Live Operations" });
  room = created.data.channel;
}

const token = await pg.tokens.create({
  identifierId: "node_dispatch",
  identifierLabel: "Node Dispatch",
  allowedChannels: [room.slug],
});

const socket = await pg.channel(room.slug).connect({
  clientToken: token,
  onMessage: console.log,
});
socket.sendEvent("dispatch.ready", { data: { ready: true } });

Notes

Use separate identifier IDs for separate logical clients. A browser connection should use its own short-lived token rather than reusing a server identity.