Connect to the Live API
Use WebSockets via socket.io to receive real-time updates from your server. By default, the websocket is attached to your Express webserver and is reachable at the /api/live path.
javascript
import { io } from "socket.io-client";
// Connect to the live endpoint
const socket = io(window.location.origin, {
path: "/api/live",
auth: {
token: "...",
}
});
socket.on("connect", () => {
console.log("Connected to Live API!");
});Authenticate Your Connection
All websocket connections require authentication for security and performance reasons. There is no public websocket endpoint provided by default.
WARNING
If you require a public websocket endpoint, you must manually implement a second connection handler.
Use the Baseline Client
The baseline client library simplifies implementation by handling authentication automatically and establishing a connection as soon as the user is authenticated. You can listen for real-time events using the .socket property:
javascript
// Listen for incoming messages
baseline.socket.on("message", (data) => {
console.log("Received message:", data);
});Tip
Check out Live Filtered Lists.