Rerun
Rerun visualizes multimodal, time-indexed data – 3D scenes, images, plots, text logs – logged from Python under entity paths and scrubbed along a shared timeline. @render_rerun keeps each Shiny session’s data separate by building its own recording, and its selected() accessor reports what the user clicked in the viewer, reactively.

A streaming patrol route, paused with an obstacle selected. See the showcase.
Installation
pip install 'shinywidgets[rerun]'This installs rerun-sdk[notebook] (rerun-sdk plus the rerun-notebook anywidget).
The viewer’s JavaScript/Wasm bundle loads from rerun’s CDN by default. Set the RERUN_NOTEBOOK_ASSET environment variable to serve-local (serves it from the Shiny process over a loopback thread server – local development only, since the browser must reach the same host) or inline (embeds it in the comm-open message; works for remote deployments too) to avoid the CDN. Every example below sets serve-local for that reason.
Quick start
A recording built from a looping path, a moving point, and a scalar series. The recording is created inside the render function (one per session), and the viewer is left at its default size, which shinywidgets expands to fill the card:
from __future__ import annotations
import os
# Serve the viewer's JS/Wasm bundle from the Shiny process instead of rerun's
# CDN (see "Installation" in the guide for why). Shiny Express auto-displays
# any top-level expression's value, so this is an `if`, not `.setdefault()`
# (whose return value would otherwise render as page text).
if "RERUN_NOTEBOOK_ASSET" not in os.environ:
os.environ["RERUN_NOTEBOOK_ASSET"] = "serve-local"
import numpy as np
import rerun as rr
from rerun.notebook import Viewer
from shiny.express import ui
from shinywidgets import render_rerun
ui.page_opts(title="rerun quickstart", fillable=True)
with ui.card(full_screen=True):
@render_rerun
def viewer():
# Create the recording inside the render function so each session
# gets its own -- never the global rr.init()/rr.log() pattern, which
# would mix every session's data into one recording.
rec = rr.RecordingStream(application_id="quickstart")
rng = np.random.default_rng(0)
t = np.linspace(0, 4 * np.pi, 120)
path = np.column_stack([np.cos(t) * t, np.sin(t) * t, t * 0.1])
rec.log("world/path", rr.LineStrips3D([path]), static=True)
for i in range(0, len(path), 4):
rec.set_time("step", sequence=i)
rec.log("world/robot", rr.Points3D([path[i]], radii=0.3, colors=[(239, 71, 111)]))
rec.log("robot/speed", rr.Scalars(1.0 + 0.4 * np.sin(i / 8) + rng.normal(0, 0.05)))
return Viewer(width="auto", height="auto", recording=rec)
Rerun auto-picks a layout from what you logged – here, a 3D view next to a timeseries plot, with no blueprint specified at all. rec.set_time("step", sequence=i) stamps each subsequent log() call on a timeline named step, which the viewer’s bottom panel turns into a scrubber.
A plain @render_widget also renders a rerun.notebook.Viewer – use @render_rerun for the typed .selected() accessor and a narrower ImportError message when the extra isn’t installed.
Overview
A look at what you can build. Click any of them to open the app, with its code, in Shinylive.
A streaming patrol route, paused and inspected
A 3D scene, camera feed, and telemetry on one timeline
Selection highlights a linked plot
Click an entity, read it back in Python
The robot keeps moving after the viewer opens
A Shiny slider scrubs the timeline
A blueprint lays out views deliberately
Log more data without rebuilding the viewer
A starting template for your own live tracker
Reacting to interaction
Every @render_rerun output has one accessor, viewer.selected(), that reports what the user clicked in the viewer – an entity, a view, or a container. Call it from any reactive context, the same way you’d call input.my_slider().
Click an entity for detail
The viewer reports which entity, view, or container is selected – not what was logged there. Keep your own history (keyed by entity path) if you want a detail panel showing the data behind the click:
@render_rerun
def viewer():
rec = rr.RecordingStream(application_id="selection_demo")
t = np.linspace(0, 4 * np.pi, N_STEPS)
r = 1.5 + 0.12 * t
path = np.column_stack([r * np.cos(t), r * np.sin(t), np.zeros(N_STEPS)])
HISTORY["world/robot"] = []
for i, p in enumerate(path):
rec.set_time("step", sequence=i)
rec.log("world/robot", rr.Points3D([p], radii=0.3, colors=[(239, 71, 111)]))
HISTORY["world/robot"].append((i, *p))
rec.log(
"world/obstacles",
rr.Boxes3D(centers=OBSTACLES, half_sizes=[(0.4, 0.4, 0.6)] * 2, colors=[(17, 138, 178)]),
static=True,
)
HISTORY["world/obstacles"] = [
(i, *center) for i, center in enumerate(OBSTACLES)
]
return Viewer(width="auto", height="auto", recording=rec)The detail card looks the clicked entity path up in that history (examples/05_selection.py):
@render.ui
def detail():
evt = viewer.selected()
if evt is None:
return ui.p("(nothing selected yet -- click an entity in the 3D view or the stream tree)")
if not evt.items:
return ui.p("Nothing selected -- click an entity in the 3D view or the stream tree.")
item = evt.items[0]
if not isinstance(item, EntitySelectionItem):
return ui.p(f"Selected a {type(item).__name__}, not an entity.")
rows = HISTORY.get(item.entity_path, [])
return ui.TagList(
ui.h5(item.entity_path),
ui.p(f"{len(rows)} logged value(s)"),
ui.tags.table(
ui.tags.thead(ui.tags.tr(ui.tags.th("#"), ui.tags.th("x"), ui.tags.th("y"), ui.tags.th("z"))),
ui.tags.tbody(
*[
ui.tags.tr(
ui.tags.td(str(i)),
ui.tags.td(f"{x:.2f}"),
ui.tags.td(f"{y:.2f}"),
ui.tags.td(f"{z:.2f}"),
)
for i, x, y, z in (rows[:3] + rows[-3:] if len(rows) > 6 else rows)
]
),
class_="table table-sm",
),
)

selected() returns None until the user selects something for the first time; after that it holds every later selection event. A re-render keeps the previous selection instead of resetting it, and clicking the same thing twice doesn’t re-fire.
Updating in place
.widget (what render_rerun exposes on the decorated function) is the low-level viewer; update_panels() and set_time_ctrl() live on the high-level rerun.notebook.Viewer wrapper instead, so keep a reference to the wrapper (and the RecordingStream) from inside the render function to call them later.
Logging more data while streaming
Logging more data to an already-open recording streams straight to the viewer, with no re-render:
# Holds the session's RecordingStream so the periodic effect below can log
# to the same recording the viewer is attached to (the render function
# itself runs once; new data streams in without a re-render).
recording_box: list[rr.RecordingStream] = []
@render_rerun
def viewer():
rec = rr.RecordingStream(application_id="streaming")
recording_box[:] = [rec]
rec.log("world/path", rr.LineStrips3D([PATH]), static=True)
return Viewer(width="auto", height="auto", recording=rec)
# A plain Python counter, not a reactive.Value: an effect that both reads
# and writes the same reactive.Value re-invalidates itself every tick,
# which can stall the session badly enough that no output ever flushes
# (see "Gotchas"). This effect depends on nothing
# reactive besides the timer, so a closure variable is simpler anyway.
step = [0]
@reactive.effect
def _stream() -> None:
reactive.invalidate_later(0.1)
if not recording_box:
return
rec = recording_box[0]
i = step[0] % len(PATH)
rec.set_time("step", sequence=step[0])
rec.log("world/robot", rr.Points3D([PATH[i]], radii=0.3, colors=[(239, 71, 111)]))
rec.log("robot/battery", rr.Scalars(100 - (step[0] % 200) * 0.5))
step[0] += 1Right after mount (just the path, battery full) and some time later (robot further along, battery drained, more points logged, all in the same viewer instance):


A slider scrubs the timeline
Viewer.set_time_ctrl() accepts a sequence (or duration/timestamp) directly, so any Shiny input can drive what point in time the viewer shows:
ui.input_slider("step", "Step", min=0, max=N_STEPS - 1, value=0)The effect that applies it is kept outside the render function so dragging the slider never rebuilds the viewer (examples/07_slider_scrub.py):
@reactive.effect
def _scrub() -> None:
# A Shiny slider stands in for the viewer's own timeline scrubber -- handy
# when the rest of the page (other inputs, a linked table) should drive
# "what point in time am I looking at" instead of the viewer's own UI.
if wrapper_box:
wrapper_box[0].set_time_ctrl(sequence=input.step())Dragging the slider moves the robot and both chart cursors together, exactly as if the viewer’s own timeline had been scrubbed:


Prefer logging more data (or a targeted trait/method call) over re-rendering whenever the scene’s identity hasn’t changed: re-rendering tears down and reconstructs the viewer, replaying the whole recording and resetting the user’s camera angle and selection; in-place updates don’t.
Linking widgets
Selection highlights a plotly chart
viewer.selected() naming a specific obstacle drives an in-place color update on a separate go.FigureWidget – a 3D viewer and a 2D plot, kept in sync, with the plot’s zoom/pan state untouched by the update:
def _highlight_selected_obstacle() -> None:
evt = viewer.selected()
if evt is None or not evt.items:
return
item = evt.items[0]
if not isinstance(item, EntitySelectionItem):
return
prefix = "world/obstacles/"
if not item.entity_path.startswith(prefix):
return
selected = int(item.entity_path[len(prefix) :])
with reactive.isolate():
# In place: the scatter keeps its zoom/pan state, instead of
# rebuilding the whole figure for a single color change.
scatter.widget.data[0].marker.color = [
SELECTED_COLOR if i == selected else DEFAULT_COLOR for i in range(len(OBSTACLES))
]

The same in-place-update pattern works with any renderer whose widget exposes a settable trait, e.g. ipyleaflet or itables.
Accessor reference
| Accessor | Returns | Before any interaction | Across a re-render | Default rate policy |
|---|---|---|---|---|
selected() |
rerun.notebook.SelectionChangeEvent (.items: a list of EntitySelectionItem, ViewSelectionItem, ContainerSelectionItem) |
None until the user first selects something |
kept (a new viewer’s empty selection doesn’t overwrite it) | not rate-limited – every selection change publishes |
selected()
evt.items[0] is the first selected item: an EntitySelectionItem, ViewSelectionItem, or ContainerSelectionItem, depending on what the user clicked. Check isinstance before reading entity-specific fields like entity_path, as the detail-card example above does.
Beyond the accessor: reactive_read
There’s nothing else worth reading reactively on this widget. Interactions other than selection – play, pause, scrubbing, opening a recording – arrive as one-off events; use Viewer.on_event() for those, or set_time_ctrl() for the programmatic equivalent of scrubbing.
Tuning accessors
Reading on demand
selected() is live from the moment the viewer renders, not from the first read, so a selection made before anything reads it is still there. That makes it safe to read from a reader that only runs after the user has already interacted: a button, a download handler, or a chat tool call (see Read on demand). examples/09_read_on_demand.py gates the read behind a button – click an entity first, then click “Show current selection”:
# Read on demand: nothing in this app reads `viewer.selected()` until the
# button's gated reader runs. Click an entity in the 3D view or the stream
# tree FIRST, then click "Show current selection": the selection you already
# made is there, because the accessor attached and started recording the
# moment the viewer rendered, not on its first read.
from __future__ import annotations
import os
if "RERUN_NOTEBOOK_ASSET" not in os.environ:
os.environ["RERUN_NOTEBOOK_ASSET"] = "serve-local"
import rerun as rr
from rerun.notebook import Viewer
from shiny import reactive
from shiny.express import input, render, ui
from shinywidgets import render_rerun
ui.page_opts(title="Read the selection on demand", fillable=True)
with ui.layout_columns(col_widths=(8, 4)):
with ui.card(full_screen=True):
@render_rerun
def viewer():
rec = rr.RecordingStream(application_id="read_on_demand_demo")
rec.log(
"world/obstacles",
rr.Boxes3D(
centers=[[2.4, 1.2, 0.3], [-1.6, -2.6, 0.3]],
half_sizes=[(0.4, 0.4, 0.6)] * 2,
colors=[(17, 138, 178)],
),
static=True,
)
rec.log(
"world/robot",
rr.Points3D([[0, 0, 0]], radii=0.3, colors=[(239, 71, 111)]),
)
return Viewer(width="auto", height="auto", recording=rec)
with ui.card():
ui.card_header("Click an entity, THEN the button")
ui.input_action_button("show", "Show current selection")
@render.code
@reactive.event(input.show)
def selection_out():
evt = viewer.selected()
if evt is None or not evt.items:
return "(nothing selected -- click an entity first)"
return "\n".join(
f"{type(item).__name__}: {getattr(item, 'entity_path', item)}"
for item in evt.items
)Rate limiting
selected() is not rate-limited and has no default rate_policy/rate_delay – a user can only select so fast, and every selection change is cheap to react to. The renderer’s rate_policy/rate_delay kwargs still apply to reactive_read() on the widget’s other traits, just not to selected().
Large data
Rerun is built around “only send what’s visible” over time: you log a continuous stream and the viewer scrubs a timeline rather than re-rendering a static scene – see Large data & performance’s three approaches. Rerun’s web viewer caps recording memory at 2.5 GB by default and drops the oldest data once it’s full; budget a long-running stream’s data rate against that ceiling, since the notebook Viewer/RecordingStream used here has no memory_limit option of its own.
Layout and sizing
In a filling layout, leave width/height at their Python defaults (both 640) or pass "auto" explicitly – shinywidgets fills the output’s card either way. An explicit integer height (e.g. Viewer(height=300, ...)) opts out of filling. output_widget(height=...) on the Shiny side also sizes a default-sized viewer to the output’s height, independent of the viewer’s own height= trait.
full_screen=True on the containing card works as expected – the viewer re-measures and refills on resize or maximize, independent of the viewer’s own maximize button.
Gotchas
- With rerun’s usual
rr.init()+rr.log(), every session sees every other session’s data. Create arr.RecordingStream(application_id=...)per session and pass it asViewer(recording=rec). rr.notebook_show()shows nothing in Shiny and discards the logged data. Return arerun.notebook.Viewerinstead.- Sizing traits accept only
"auto"or an integer pixel count; any other string ("100%","50vh") silently falls back to the 640x480 default. Use"auto"for filling, an integer for a fixed size.
Learn more
- rerun.io/docs
- rerun-notebook on PyPI
- Related guides: pyvista and k3d for static 3D without a time axis; plotly or altair for 2D charts alone.



