Skip to Content
Runlane
Realtime

Realtime overview

Show a run's status, progress, and streamed output in your app while the task works.

Realtime lets your app show a run while it works. A page can show the run's status, a progress bar, and text as the task writes it. You do not need to poll.

Realtime covers two kinds of data:

  • Run updates: the run's status, metadata, and final output. You get a new value each time one of them changes.
  • Streams: data the task writes while it runs, such as AI tokens or log lines. You get each part as soon as it is saved.
Run updatesStreams
What you getStatus, metadata, and final outputEach part the task appends
When it updatesWhen the run changesEach time the task appends a part
Good forStatus badges, progress bars, resultsAI answers, live logs, long reports
Task codeNothing extra. Call context.updateMeta() to report progress.Declare streams on the task and call context.stream(name).append().
React hookuseRunuseRunStream
Plain clientclient.subscribe()client.readStream()

Most pages use both: useRun for the status and useRunStream for the live text.

How it works

worker  ── saves status, metadata, and parts ──> storage
                                                    │
browser ── opens a connection ──> your server ── reads ──┘
        <── sends each change ──  (realtime.handle)
  1. Your task runs on a worker. It saves status, metadata, and stream parts to storage, as usual.
  2. You mount one handler, realtime.handle, in your own server. Runlane does not host it for you.
  3. The browser opens a long-lived HTTP connection to that handler. This uses server-sent events (SSE): one response that keeps sending events.
  4. On every connection, the handler checks that this user may read this run. It then sends a snapshot of the run, followed by each change.
  5. If the connection drops, the client reconnects and continues where it stopped. It does not repeat or skip parts.

The worker and the handler can run in different processes. They only share storage.

What you install

Import fromRuns inGives you
@runlane/realtimeYour servercreateRunlaneRealtime(): the HTTP handler and token minting
@runlane/realtime/clientBrowser or Node.jscreateRunlaneClient(): reads runs and streams
@runlane/reactReact 19 appsRunlaneProvider, useRun, and useRunStream

@runlane/realtime/client is part of the @runlane/realtime package. React apps install @runlane/realtime and @runlane/react.

Next steps

Common questions

Do I need WebSockets or polling?

No. The handler uses server-sent events over normal HTTP. The client reconnects for you.

Who decides who can see a run?

You do. Every connection runs your authorize check, or checks a token that your server signed. Runlane has no built-in user model. See authorize readers.

Is the task's input sent to the browser?

No. The browser gets a short list of safe fields. Payloads, tags, and error stack traces are never sent. See the run object.

What happens when a task retries?

A retry starts a new attempt, and the task may write a new answer. By default, useRunStream clears the text when a new attempt starts. You never see two answers joined together. See retries and attempts.

Does closing the page cancel the run?

No. Unmounting a component or calling stop() only closes the connection. The run keeps going. To cancel it, call runlane.runs.cancel(runId) on your server. See cancel runs.

Where do I write the stream from the task?

In the task's run function. See stream run output for appends, batches, and piping a model's output.

On this page