Set up live updates
1
Open a session
Add an endpoint on your server that the browser calls when it needs live updates for specific apps. Check that the signed-in builder has access to each of those apps. Then use Create socket session to open a short-lived session that lets the browser watch those apps:The response carries
session_id, session_token, socket_url, and socket_path. Return session_token, socket_url, and socket_path to the browser, and keep session_id on your server.A session watches up to eight apps for one hour, and expires_in gives that time in seconds. Sessions are never extended, so open a new one on every call and don’t return a cached token.2
Connect from the browser
The browser connects with the session your endpoint returns, using the Platform SDK. Install Each browser tab needs its own session. A second connection with the same token replaces the first, so don’t share a token between tabs. If the connection drops, the SDK retries five times and rejoins every active subscription with a fresh snapshot. The SDK calls
@base44/platform, create a client with createPlatformClient(), and call client.chat.init() once per page.In the options, pass a getSession() function that calls the endpoint you added in the previous step and returns its JSON. The SDK connects to the socket_url and socket_path in that JSON.Then subscribe to each app you want to watch, connect, and clean up when the page closes:getSession() again when the session expires or Base44 rejects its token. For every option and method, see the client reference.3
Apply snapshots and events
When you subscribe to an app, Look up any event and its fields in Socket messages. If an error comes back,
onSnapshot() receives the app’s current state first, including the build status, the last 50 messages, and the prompt queue. Then onEvent() receives each live event, in order.Follow these rules when you apply a snapshot or an event:- Replace: Replace what you hold for the app with the snapshot, including the build status, the messages, and the prompt queue. To show older history, load it with Read conversation messages.
- Missing isn’t empty: If an event leaves out a field, keep the value you have. If an event sets a field to
null, clear it. - Branches: An event with a
branch_idbelongs to that branch. An event with nobranch_id, or withbranch_idset tonull, belongs to the main branch.
Live messages and HTTP messages are different shapes. The transcript from Read conversation messages carries the AI’s raw tool calls. Live messages carry only the fields listed in Socket messages. Map the HTTP messages into the live shape so one set of components renders both.
PlatformSocketError explains each code and what to do about it.Change a session’s apps
You can change which apps a session watches at any time from your server. Using thesession_id you kept in the first step, call Add app to session to add an app or Remove app from session to remove one. After you remove an app, a connected browser stops receiving its updates right away. When the page closes, call End socket session from your server to end the session and disconnect the browser.
Answer questions
During a build, the AI sometimes pauses to ask a question. The question arrives as a tool call inmessage.updated, with status set to waiting_for_user_input. Show the question in the browser. Your server then sends the answer with Submit tool-call input, the same call you use in the build turn.
See also
- Socket sessions: The endpoints that open, change, and end a session
- Socket messages: Every message on the connection and the fields it carries
PlatformSocketError: What each error code means, and what to do about it- The build turn: The calls that create, answer, and ship an app
- Tenancy and credentials: What reaches the browser, and what stays on your server