Skip to main content

StreamTree

PyPI version Python versions Docs License CI Ruff

Declarative, typed composition for Streamlit. Build UI as Python data (@component functions return element trees); the renderer maps them to st.* on each rerun. No separate frontend build.

Documentation (primary): streamtree.readthedocs.io — getting started, recipes, full example source, guides, API reference, and changelog.

At a glance

Without StreamTree With StreamTree
Long imperative scripts @component + layouts/widgets as a tree
Ad hoc session_state keys state() scoped to the render path
Hard to test structure streamtree.testing.render_to_tree() and summarize_tree_kinds()

Includes: layouts (Page, VStack, Form, Routes, …), optional [tables] / [charts] / [ui] / [auth], streamtree.asyncio task helpers, multipage discovery in streamtree.helpers.pages, optional [cli] (streamtree run, doctor, init, tree, …). Details, version notes, and extras matrix live in the docs.

Requirements

Python 3.10+, Streamlit ≥ 1.33, Pydantic v2 (see pyproject.toml).

Install

pip install streamtree
pip install "streamtree[cli]"    # Typer + streamtree run / doctor / init / tree
# Optional: [tables] [charts] [ui] [auth] — see Dependency strategy on RTD

From a clone (contributors):

git clone https://github.com/streamtree-dev/streamtree.git
cd streamtree
uv sync --extra dev

Quick start

from streamtree import component, render
from streamtree.elements import Button, Card, Page, Text
from streamtree.state import state


@component
def Counter():
    count = state(0)
    return Card(
        Text(f"Count: {count()}"),
        Button("Increment", on_click=lambda: count.increment(1)),
        Button("Reset", on_click=lambda: count.set(0)),
    )


if __name__ == "__main__":
    render(Page(Counter()))
streamlit run examples/counter.py
# with [cli]:  streamtree run examples/counter.py

More patterns (interop with raw st.*, App / theme, async, routing, multipage, CRUD) are in the recipes and examples sections on Read the Docs.

Documentation map

Start here Read the Docs
Install & mental model Getting started
How-to cookbook Recipes
Every examples/*.py inlined Examples (full source)
Testing & AppTest Testing & debugging
Plan, roadmap, deps, performance, phases Guides (use the site nav: Design & roadmap / Operations)
Release history Changelog

Design files remain in docs/ in the repo; the site above is the supported reading path for stable releases.

Contributing

uv sync --extra dev
uv run ruff format --check .
uv run ruff check src tests
uv run ty check src
uv run pytest
uv run python -m mkdocs build --strict
uv build

Same checks with pip: pip install -e ".[dev]", then the same ruff, ty, pytest, mkdocs build --strict, and uv build (or python -m build). Coverage is enforced at 100% on src/streamtree (see pyproject.toml). GitHub Actions live under .github/workflows/ (ci.yml, release.yml, and reusable-*.yml); you can re-run CI manually via Actions → CI → Run workflow.

Releases

Before tagging v*.*.*: align pyproject.toml version, CHANGELOG.md, and package metadata (see tests/test_package_meta.py). CI and the release workflow run lint, typecheck, tests, MkDocs, and uv build; publishing needs a valid PyPI token or trusted publishing setup (details in workflow comments and PyPI docs).

Limits (Streamlit)

No stable cross-rerun APIs for arbitrary widget focus or DOM control. Prefer session_state, query params (streamtree.routing, …), st.rerun, and key= discipline. Portal / PortalMount move subtrees within a script; they do not replace Streamlit’s execution model. See Portals & prefetch on RTD.

License

MIT — LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamtree-0.11.0.tar.gz (154.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamtree-0.11.0-py3-none-any.whl (64.6 kB view details)

Uploaded Python 3

File details

Details for the file streamtree-0.11.0.tar.gz.

File metadata

  • Download URL: streamtree-0.11.0.tar.gz
  • Upload date:
  • Size: 154.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for streamtree-0.11.0.tar.gz
Algorithm Hash digest
SHA256 89bb94bc8a831093c4f53227eeb753b8197e88ac55b99cc00e160779799aa650
MD5 3ce3f262aff2df2781f41b8d66d0834f
BLAKE2b-256 c2290f8bbff0e1afd13ca74710da8bd575efbbcd30a2258f3f592e4820521f28

See more details on using hashes here.

File details

Details for the file streamtree-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: streamtree-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 64.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for streamtree-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dad8e80b0ffa02ba866c441682f1f1e5c365f3a8462b678b39e3a942cbb5e53a
MD5 6254ebe0d5a58cd366b0655beb148616
BLAKE2b-256 3dc6f440dab5b3f0271611c4e02b6824f2fd8929c568d7dc69bb60d4fd361f8d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.11.0 This release

2 files

0.10.0

2 files

0.9.0

2 files

0.8.0

2 files

0.7.1

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page