Skip to main content

Wybthon

SolidJS for Python. Build interactive web apps in Python, no JavaScript required.

CI Release PyPI Version Python Versions License: MIT Docs

Documentation · Getting Started · Examples · Contributing


Overview

Wybthon brings SolidJS 2.0's reactive model to Python and runs it in the browser through Pyodide. You write run-once function components, return a tree of HTML helpers, and drop signals, memos, and small reactive expressions ("holes") into that tree. When a signal changes, only the holes that read it re-run; components never re-render. Async data, loading and error boundaries, actions with optimistic state, draft-first stores, a router, forms, and context are all built in.

Features

  • Run-once components with typed props. @component functions run once at mount. Every parameter is a Prop[T] accessor: call it for a tracked read, .peek() for a one-time read, or place it in the tree to bind it.
  • Reactive holes, not re-renders. Any zero-argument callable or accessor placed in the tree becomes its own render effect. A signal write re-runs only the holes that depend on it.
  • Signals with automatic batching. create_signal, create_memo, and create_effect. Writes are staged and applied once per microtask (and at the end of every event handler), so there is no batch() to remember.
  • Async-first data. An async def passed to create_memo is the data-fetching primitive. Loading shows a fallback until it resolves, later refetches serve the stale value while revalidating, and is_pending, latest, resolve, and refresh observe or drive it.
  • Actions and optimistic state. action tracks in-flight mutations; create_optimistic and create_optimistic_store hold temporary values that revert when the actions settle.
  • Draft-first stores. create_store setters take a function that mutates a draft with plain Python; reads are tracked per path. reconcile, snapshot, deep, derived stores, and projections are included.
  • Flow control. Show, For, Repeat, Switch/Match, and Dynamic create isolated reactive scopes so only the affected subtree updates.
  • Boundaries. Loading, Reveal, and Errored keep content mounted while pending and swap in fallbacks without tearing down sibling trees.
  • Virtual DOM behind the scenes. Every DOM mutation is batched through a small JS kernel in a single Python-to-JS crossing, and static subtrees mount from cloned templates.
  • Router, forms, context, portals, lazy components. Router, Route, Link, form_state with validators and ARIA helpers, callable Context objects, Portal, and lazy.
  • Dev mode diagnostics. Writes inside a tracking scope raise WriteInScopeError; untracked reads at the top of a component body warn.
  • Dev server with hot reload. wyb dev serves your project and reloads the page over Server-Sent Events.

Quick start

Installation

Wybthon requires Python 3.12 or newer.

pip install wybthon

Inside Pyodide, install at runtime with micropip:

import micropip
await micropip.install("wybthon")

Usage

from wybthon import (
    Errored,
    For,
    Loading,
    Prop,
    Show,
    action,
    button,
    component,
    create_memo,
    create_signal,
    create_store,
    div,
    input_,
    li,
    p,
    prop,
    render,
    ul,
)


@component
def Counter(step: Prop[int] = prop(1)):
    count, set_count = create_signal(0)
    doubled = create_memo(lambda: count() * 2)
    return div(
        p("Count: ", count, " (doubled: ", doubled, ")"),
        button("+", on_click=lambda e: set_count(lambda n: n + step())),
        Show(lambda: count() > 5, lambda: p("That's a lot of clicks.")),
    )


@component
def Todos():
    store, set_store = create_store({"items": []})
    draft, set_draft = create_signal("")

    @action
    async def add(title: str):
        set_store(lambda s: s.items.append({"id": len(s.items) + 1, "title": title}))
        set_draft("")

    return div(
        input_(value=draft, on_input=lambda e: set_draft(e.target.value)),
        button("Add", on_click=lambda e: add(draft.peek()), disabled=add.pending),
        ul(For(lambda: store.items, lambda item, i: li(lambda: item()["title"]), keyed=lambda t: t["id"])),
    )


@component
def App():
    return Errored(
        lambda: Loading(lambda: div(Counter(step=2), Todos()), fallback=p("Loading...")),
        fallback=lambda err, reset: div(p("Something went wrong: ", str(err)), button("Retry", on_click=lambda e: reset())),
    )


render(App(), "#app")

Documentation

Visit wybthon.com for the full documentation, including getting started guides, core concepts, API reference, working examples, and migration guides from React, Solid, and earlier Wybthon releases.

Contributing

Contributions are welcome. Please see CONTRIBUTING.md for setup instructions, coding standards, and guidelines for submitting pull requests.

License

MIT

Download files

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

Source Distribution

wybthon-0.31.0.tar.gz (146.9 kB view details)

Uploaded Source

Built Distribution

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

wybthon-0.31.0-py3-none-any.whl (124.8 kB view details)

Uploaded Python 3

File details

Details for the file wybthon-0.31.0.tar.gz.

File metadata

  • Download URL: wybthon-0.31.0.tar.gz
  • Upload date:
  • Size: 146.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for wybthon-0.31.0.tar.gz
Algorithm Hash digest
SHA256 82108e6c671a94559ceaf7576fcd261f24d71f80a3415dcf9b5f790cd8779035
MD5 829c4e070d41bccc640a4621ff60c9d3
BLAKE2b-256 c62c578b1397876beb9aec6126e0ba2304712d4233edb2f6c06365492fadebe8

See more details on using hashes here.

Provenance

The following attestation bundles were made for wybthon-0.31.0.tar.gz:

Publisher: release.yml on wybthon/wybthon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wybthon-0.31.0-py3-none-any.whl.

File metadata

  • Download URL: wybthon-0.31.0-py3-none-any.whl
  • Upload date:
  • Size: 124.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for wybthon-0.31.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2cce25272b25594268408ae1bbbb575f1c9dd7a1f854a230fa136b21125fbcaa
MD5 38b675703e00a1d6a1e45d68a73f459f
BLAKE2b-256 f2e5ac5f4f5303b0cfc8c08bdfbe803d0fbbfe935eef9f753ad545bcc31606f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for wybthon-0.31.0-py3-none-any.whl:

Publisher: release.yml on wybthon/wybthon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.32.0

2 files

This release

0.31.0 This release

2 files

0.30.0

2 files

0.29.0

2 files

0.28.0

2 files

0.27.0

2 files

0.26.0

2 files

0.25.0

2 files

0.24.0

2 files

0.23.1

2 files

0.23.0

2 files

0.22.0

2 files

0.21.0

2 files

0.20.0

2 files

0.19.0

2 files

0.18.0

2 files

0.17.0

2 files

0.16.0

2 files

0.15.0

2 files

0.14.0

2 files

0.13.0

2 files

0.12.0

2 files

0.11.0

2 files

0.10.0

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

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