Skip to main content

reflex-jupyter-renderer-react

PyPI version Python versions License: MIT GitHub

A native Reflex component that wraps the jupyter-renderer-react React library, so you can render Jupyter notebooks (.ipynb) in a Reflex app — with syntax highlighting, markdown, rich outputs, theming, collapsible cells and copy-to-clipboard — in pure Python. No HTML, no iframe, no hand-written JavaScript.

import reflex as rx
from reflex_jupyter_renderer_react import (
    jupyter_notebook_viewer, Notebook, MarkdownCell, CodeCell, stream_output,
)

nb = Notebook(cells=[
    MarkdownCell("# Hello, notebook"),
    CodeCell("print('hi')", execution_count=1, outputs=[stream_output("hi\n")]),
])

def index() -> rx.Component:
    return jupyter_notebook_viewer(notebook=nb.to_dict(), theme="dark")

app = rx.App()
app.add_page(index)

Why a native component?

iframe / pre-rendered HTML native component (this package)
Isolated from app state Wired into Reflex state via events (on_file_load, on_error, …)
Tied to static files/routes Reusable, pip install-able
Untyped JSON edited by hand Typed Python builders for notebooks
External hosting / manual embedding npm dependency resolved by Reflex automatically

Requirements

  • Python ≥ 3.11
  • Reflex ≥ 0.10.0 (tested with Reflex 0.10.0, Python 3.11 – 3.14)

Install

pip install reflex-jupyter-renderer-react
# or, with uv:
uv add reflex-jupyter-renderer-react
# or, from this repo (editable):
uv pip install -e .

Reflex installs the underlying npm package (@iomete/jupyter-renderer-react@1.0.1) into the compiled frontend automatically on the first reflex run.

Usage

Three ways to supply a notebook

from reflex_jupyter_renderer_react import (
    jupyter_notebook_viewer, JupyterNotebookViewer, Notebook, MarkdownCell, CodeCell,
    load_notebook,
)

# 1) Typed Python builders
nb = Notebook(cells=[MarkdownCell("# Title"), CodeCell("1 + 1", execution_count=1)])
jupyter_notebook_viewer(notebook=nb.to_dict())

# 2) A raw JSON string
jupyter_notebook_viewer(notebook='{"cells": [], "nbformat": 4, "nbformat_minor": 4}')
# or: JupyterNotebookViewer.from_json(json_str)

# 3) Load from a URL or from disk
JupyterNotebookViewer.from_url("https://example.com/notebook.ipynb")
jupyter_notebook_viewer(notebook=load_notebook("assets/demo-example.ipynb"))

Props

Prop Type Default Description
notebook dict | str required Parsed dict, JSON string, or {"filePath": "..."}.
theme str | dict "light" "light", "dark", or a custom theme object.
show_cell_numbers bool True Show execution count for code cells.
show_outputs bool True Render cell outputs.
collapsible bool False Allow cells to collapse.
copyable bool True Copy button on code cells.
class_names dict {} Per-part class names (classNames).
styles dict {} Per-part inline styles (styles).
fetch_options dict {} {"headers": {...}, "timeout": 10000} for URL loading.

Reflex converts snake_case props to camelCase automatically (show_cell_numbers → showCellNumbers).

Events → Python

class State(rx.State):
    status: str = "idle"

    @rx.event
    def loaded(self, notebook: dict):
        self.status = f"{len(notebook.get('cells', []))} cells loaded"

    @rx.event
    def failed(self, message: str):
        self.status = f"error: {message}"

JupyterNotebookViewer.from_url(
    "https://example.com/notebook.ipynb",
    fetch_options={"timeout": 10000},
    on_file_load=State.loaded,
    on_file_error=State.failed,
)
Event Payload Fires when
on_file_load notebook: dict A notebook is fetched from a filePath.
on_file_error message: str File loading fails (network / 404 / timeout).
on_error message: str Parsing / rendering fails.

Demo app

A full demo lives in jupyter_renderer_react_demo/ and exercises every feature (typed builders, JSON string, URL loading with events, custom styles, and live theme/prop toggles).

uv pip install -e .
cd jupyter_renderer_react_demo
uv run reflex run

Building notebooks in Python

from reflex_jupyter_renderer_react import (
    Notebook, MarkdownCell, CodeCell,
    stream_output, execute_result_output, error_output,
)

nb = Notebook(cells=[
    MarkdownCell("# Report"),
    CodeCell("print('hi')", execution_count=1, outputs=[stream_output("hi\n")]),
    CodeCell("2 ** 10", execution_count=2,
             outputs=[execute_result_output({"text/plain": "1024"}, execution_count=2)]),
    CodeCell("1/0", execution_count=3,
             outputs=[error_output("ZeroDivisionError", "division by zero")]),
])
data = nb.to_dict()

The data-model layer (Notebook, cells, output factories, load_notebook) imports without Reflex installed, so it is usable in plain scripts and unit tests.

Naming note

The upstream project has some naming inconsistencies. This wrapper centralizes them in overridable constants and defaults to the public, documented contract:

Source Name
Public README usage JupyterNotebookViewer
src/index.ts export JupiterNotebookViewer (sic)
package.json name @iomete/jupyter-renderer-react (GitHub registry)

Defaults match what the published npm package actually ships: library = "@iomete/jupyter-renderer-react@1.0.1", tag = "JupiterNotebookViewer" (the Python class is still named JupyterNotebookViewer). To retarget the unscoped name or the README-spelled tag:

import reflex_jupyter_renderer_react.jupyter_renderer_react as j
j.JupyterNotebookViewer.library = "jupyter-renderer-react"
j.JupyterNotebookViewer.tag = "JupyterNotebookViewer"

You can also change the pinned npm version via LIBRARY_VERSION in src/reflex_jupyter_renderer_react/jupyter_renderer_react.py.

Development

This project follows the Reflex custom component workflow and uses uv.

uv sync --all-extras          # create .venv with Reflex + dev tools
uv run ruff check .           # lint
uv run pytest                 # run the tests
uv build                      # -> dist/ (sdist + wheel with generated .pyi stubs)

Reflex 0.10 note: the reflex component CLI (init / build / publish / share) was removed in Reflex 0.10. This package now follows the official component template: the build backend is hatchling and the hatch-reflex-pyi hook generates the .pyi type stubs during uv build.

Releasing

CI (.github/workflows/ci.yml) runs lint + tests on Python 3.11–3.14, builds the package and compiles the demo on every push and pull request. Publishing to PyPI is done by .github/workflows/publish.yml via trusted publishing when a v* tag is pushed:

  1. Bump version in pyproject.toml and add a CHANGELOG.md entry; merge to main.

  2. Tag main and push the tag (it must match the version):

    git checkout main && git pull
    git tag v0.2.0
    git push origin v0.2.0
    

See specs/ for the full Spec-Driven Design documentation: PRD, architecture, API, data-model schema, and the phased implementation plan & tasks.

Project structure

reflex-jupyter-renderer-react/
├── src/reflex_jupyter_renderer_react/
│   ├── __init__.py
│   ├── jupyter_renderer_react.py   # the Reflex component
│   └── models.py                   # dependency-free notebook builders
├── .github/workflows/              # ci.yml (tests/build/demo) · publish.yml (PyPI on tag)
├── jupyter_renderer_react_demo/    # runnable demo app
├── tests/                          # data-model + component contract tests
├── specs/                          # SDD: prd / technical / api / data-model / plans
├── pyproject.toml
├── README.md · CHANGELOG.md · LICENSE

License

MIT © Ernesto Crespo. The upstream jupyter-renderer-react library is also MIT.

Metadata

Release files for reflex-jupyter-renderer-react 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for reflex-jupyter-renderer-react 0.2.0
File Size Uploaded Provenance
reflex_jupyter_renderer_react-0.2.0.tar.gz 51.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for reflex-jupyter-renderer-react 0.2.0
File Interpreter ABI Platform
reflex_jupyter_renderer_react-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 65.1 kB

Release files / reflex_jupyter_renderer_react-0.2.0.tar.gz

Download URL reflex_jupyter_renderer_react-0.2.0.tar.gz
Size 51.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e8703cb0a4ecd96c06c70c89de37f844347276d95381383ee69a3bd3ec455f8f
BLAKE2b-256 checksum
How to use checksums
8f8bd11c1ba27d57be15953bc726284fc871b3190be643097827ab2ef53293cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / reflex_jupyter_renderer_react-0.2.0-py3-none-any.whl

Download URL reflex_jupyter_renderer_react-0.2.0-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
421ead36c21093c0fa007db9dd170f5d786ca65f9ec0d15017e42104c8241548
BLAKE2b-256 checksum
How to use checksums
9b442892c5d07d61288fb7f8916943d29794b06de980820e62b462ba1c2198fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for reflex-jupyter-renderer-react 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for reflex_jupyter_renderer_react-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page