Skip to content

Run R + plots in the browser

Your R code never leaves the browser. Execution happens entirely inside a Web Worker in this page. No network request carries your cell source. WebR’s R runtime is fetched once from its CDN on first run, then cached — nothing else is sent.

Edit any cell, then press Shift+Enter (or ▶) to run. Plots are captured as PNG from R’s graphics device and displayed inline:

What’s running

  • @jupyter-kit/executor-webr wraps the webr npm package.
  • WebR boots R (compiled to WebAssembly) inside a Web Worker.
  • R graphics are rendered to an OffscreenCanvas, converted to base64 PNG, and displayed as a Jupyter display_data output.
  • stdout / stderr / messages are captured separately and streamed.

Setup

Terminal window
pnpm add @jupyter-kit/executor-webr webr @jupyter-kit/editor-codemirror \
@codemirror/legacy-modes
import { createWebRExecutor } from '@jupyter-kit/executor-webr';
import { r as rLang } from '@jupyter-kit/core/langs/r';
import { StreamLanguage } from '@codemirror/language';
import { r as rEditor } from '@codemirror/legacy-modes/mode/r';
const executor = createWebRExecutor();
const plugins = [
createEditorPlugin({ extensions: [StreamLanguage.define(rEditor)] }),
];
<Notebook
executor={executor}
plugins={plugins}
language="r"
languages={[rLang]}
...
/>