SolidJS for Python. Build interactive web apps in Python, no JavaScript required.
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 with typed props and return HTML written as Python 3.14 template strings: html(t"<p>Count: {count}</p>"). Signals, memos, and small reactive expressions placed in that markup update only the text nodes and attributes that read them; components never re-render. Async data, loading and error boundaries, actions with optimistic state, draft-first stores, server rendering, a router, forms, and context are all built in.
Features
- HTML templates that compile once.
html(t"...")takes a PEP 750 template string. Each literal is parsed and compiled once, and every later call clones a native<template>with one command and fills its slots. It's the job Solid's compiler does for JSX, done by the language with no build step. - Run-once components with typed props. Components declare their inputs on a
Propsclass.Prop[T]fields are reactive accessors; plain fields carry callbacks untouched. Pyright, Pylance, and mypy check every component call with no plugin. - Components cost what their markup costs. A constant prop subscribes to nothing, a binding that reads nothing reactive is dropped after its first run, and
Show,For,Repeat, andSwitchare native regions rather than wrapper components. - Signals with automatic batching.
create_signal,create_memo, andcreate_effect. Writes are staged and applied once per microtask (and at the end of every event handler), so there's nobatch()to remember. - Async-first data. An
async defpassed tocreate_memois the data-fetching primitive.Loadingshows a fallback until it resolves; later refetches run as transitions that hold the dependent UI on the old state until the new value lands, so the screen never tears.is_pending,latest,resolve, andrefreshobserve or drive it. - Actions and optimistic state.
actionmakes a mutation a transaction;create_optimisticandcreate_optimistic_storeshow temporary values that revert when the action settles. - Draft-first stores.
create_storesetters take a function that mutates a draft with plain Python; reads are tracked per path.reconcile,snapshot,deep, and projections are included. - Flow control and boundaries.
Show,For,Repeat,Switch/Match, anddynamicupdate only the affected subtree;Loading,Reveal, andErroredswap in fallbacks without tearing down sibling trees. - Server rendering and hydration. Render the same components to HTML in CPython at build time or per request, stream
Loadingboundaries as they resolve, set the response status and headers from components, andhydratethe result in the browser. - One bridge crossing per update. A small virtual DOM batches every mutation in a flush into one call to a JavaScript kernel, which matters when every DOM call would otherwise cross from Python to JavaScript.
- Router, forms, context, portals, and lazy components.
wybthon.router,wybthon.formswith validators and ARIA helpers, callableContextobjects,Portal, andlazywith explicit build chunks. - Testing in plain CPython.
wybthon.testingrenders components into an in-memory DOM and queries them by text, role, label, and test id. - Tooling.
wyb initscaffolds a project,wyb devrebuilds and reloads on change, andwyb buildwrites a production bundle with the manifest inlined and the runtime preloaded.
Quick start
Installation
Wybthon requires Python 3.14.
pip install wybthon
wyb init my-app
cd my-app
wyb dev --open
Usage
from collections.abc import Callable
from wybthon import (
Errored,
For,
Loading,
ParentProps,
Prop,
Props,
Show,
action,
component,
create_memo,
create_signal,
create_store,
html,
prop,
render,
)
class CounterProps(Props):
step: Prop[int] = prop(default=1)
on_change: Callable[[int], None] | None = None
@component
def Counter(props: CounterProps):
count, set_count = create_signal(0)
doubled = create_memo(lambda: count() * 2)
many = create_memo(lambda: count() > 5)
def increment():
set_count(lambda n: n + props.step())
if props.on_change is not None:
props.on_change(count.peek() + props.step.peek())
return html(t"""
<div>
<p>Count: {count} (doubled: {doubled})</p>
<button onclick={increment}>+</button>
{Show(many, html(t"<p>That's a lot of clicks.</p>"))}
</div>
""")
class PanelProps(ParentProps):
title: Prop[str]
@component
def Panel(props: PanelProps):
return html(t'<section class="panel"><h2>{props.title}</h2>{props.children}</section>')
@component
def Todos():
store, set_store = create_store({"todos": []})
draft, set_draft = create_signal("")
@action
async def add(title: str):
set_store(lambda s: s.todos.append({"id": len(s.todos) + 1, "title": title}))
set_draft("")
def todo(item, index):
return html(t"<li>{(lambda: item().title)}</li>")
return html(t"""
<div>
<input value={draft} oninput={(lambda e: set_draft(e.target.value))}>
<button onclick={(lambda: add(draft.peek()))} disabled={add.pending}>Add</button>
<ul>{For(store.todos, todo, keyed=lambda t: t["id"])}</ul>
</div>
""")
def failed(err, reset):
return html(t"<div><p>Something went wrong: {(lambda: str(err()))}</p><button onclick={reset}>Retry</button></div>")
@component
def App():
return Errored(
Loading(
html(t"""
<main>
<{Panel} title="Counter"><{Counter} step={2} on_change={print} /></{Panel}>
<{Panel} title="Todos"><{Todos} /></{Panel}>
</main>
"""),
fallback=html(t"<p>Loading...</p>"),
),
fallback=failed,
)
render(App(), "#app")
Python doesn't allow a bare lambda inside a t-string interpolation, so inline handlers are wrapped in parentheses, as in {(lambda: ...)}, or given a name. Named handlers and memos usually read better anyway. The element helpers (div(...), p(...)) remain available when markup is built by code; see Templates.
In a project created with wyb init, return the root view from the entry function in app/main.py instead of calling render; the generated bootstrap renders it, or hydrates it when the page was prerendered. List routes under prerender in wybthon.toml to render them to HTML at build time. See Server rendering.
Components are testable in plain CPython:
from wybthon.testing import fire, render
def test_counter():
with render(Counter(step=2)) as screen:
fire.click(screen.get_by_role("button", name="+"))
assert screen.get_by_text("Count: 2 (doubled: 4)")
Documentation
Visit wybthon.com for the full documentation, including getting started guides, core concepts, API reference, working examples, and migration guides from React and Solid. Large changes are designed in RFCs.
Contributing
Contributions are welcome. Please see CONTRIBUTING.md for setup instructions, coding standards, and guidelines for submitting pull requests.
License
Metadata
Release files for wybthon 0.38.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wybthon-0.38.0.tar.gz | 315.2 kB | With provenance | Details for wybthon-0.38.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wybthon-0.38.0-py3-none-any.whl | Python 3 | none | any | Details for wybthon-0.38.0-py3-none-any.whl |
Total release size: 552.6 kB
Release files / wybthon-0.38.0.tar.gz
| Download URL | wybthon-0.38.0.tar.gz |
|---|---|
| Size | 315.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
521ad3be546a34bfc40c224978931a112b08561996859526eb515c0b7ed72fa0
|
|
BLAKE2b-256 checksum How to use checksums |
cb48d0cd7686b7d4a11d1a695a4b7d5637bdec250a91b89d17631534c5236924
|
| 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 19, 2026.
Transparency logRelease files / wybthon-0.38.0-py3-none-any.whl
| Download URL | wybthon-0.38.0-py3-none-any.whl |
|---|---|
| Size | 237.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c668b14d2ab9381a288205fbc1903d574cba027c6d6ad7e36577a8f4b60bbd5
|
|
BLAKE2b-256 checksum How to use checksums |
09281e8bdfa312e0cdb47b43167d75a275078ff5390674bb97862174d0cace4b
|
| 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 19, 2026.
Transparency logSecurity for wybthon 0.38.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.
Attestation for wybthon-0.38.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 19, 2026.
Transparency logA 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.