Skip to content

FAQ

Quick answers to the questions we get most often. If yours isn't here, check the troubleshooting guide or open an issue.

General

Is Wybthon production ready?

Not yet. The framework is pre-1.0 and the public API may shift between minor releases (old APIs are removed outright rather than shimmed). We recommend it for prototypes, internal tools, and learning projects today, and we'll relax this guidance as the API stabilizes.

Does it work outside the browser?

Everything except the real browser. Signals, memos, effects, async computations, actions, stores, forms, context, flow control, and VDOM construction run in plain CPython. wybthon.testing renders components into an in-memory DOM through the real reconciler and event delegation, so you can test them with pytest (see the testing guide), and wybthon.server renders them to HTML for prerendering and server rendering.

Which Python version do I need?

Python 3.14. Template strings (PEP 750) are part of the component API, and server rendering, tests, and tooling run on the same Python version as the browser. In the browser that means Pyodide 314 or newer; wyb init pins 314.0.6.

Why Python in the browser?

Wybthon lets data scientists, researchers, and tooling teams build interactive UIs without switching to TypeScript. Pyodide makes the scientific Python stack (NumPy, pandas, scikit-learn, and friends) available client-side, so you can render results without a server round-trip.

Why is there a virtual DOM if this is 'SolidJS for Python'?

Every DOM call crosses the Python-to-JavaScript bridge, so Wybthon batches mutations instead of making them one at a time. The VDOM is that batching layer, not a re-render model: each reactive hole diffs only its own subtree, and the reconciler sends the resulting mutations to a JavaScript kernel in one bridge crossing. The static parts of an html template never become VNodes at all. Wybthon's compiler turns each template literal into a native <template> that's cloned with one command, and its dynamic expressions into getters, which is the job Solid's compiler does for JSX. The reactive model is fine-grained; a signal change re-runs the holes that read it, never whole components.

Do I need to wrap expressions in lambdas to keep them reactive?

No. Wybthon's compiler does what Solid's does for JSX: an interpolation that contains a call, an attribute access, or a subscript ({count() * 2}, {user.name}, {row["label"]}, class={"on" if active() else ""}) becomes a getter, so it updates when what it reads changes. A component's parameter is a prop, so {title} is a getter too. Other names, constants, and lambdas are passed as they are, and event handlers and refs are never wrapped. The compiler runs when a module is imported after wybthon, in wyb build and wyb dev, under pytest, and for scripts run with wyb run script.py. See The compiler.

You still can't write a bare lambda in an interpolation: Python's grammar treats its : as the start of a format spec. Name an inline event handler, or wrap it in parentheses: onclick={(lambda: set_open(False))}.

Why does html() say my template wasn't compiled?

In dev mode, a template that reaches html without passing through the compiler raises TemplateError when one of its dynamic expressions has already been evaluated, because the markup would silently stop updating. This happens in a script run with python script.py (use wyb run script.py), at a REPL, or in code built with exec. See the troubleshooting entry.

What happened to the element helpers (div(...), p(...))?

RFC 0004 removed them, along with wybthon.elements and wybthon.svg. A helper evaluates its arguments before Wybthon sees them, so it can't benefit from the compiler. html templates are the way to write markup (including <svg>), and h(tag, props, *children) is the programmatic layer, like h in Solid: use it for markup that code builds, such as generated forms, recursive trees, or a computed tag. h() props take Python names (class_, html_for, on_click) as well as HTML names.

Pyodide and runtime

Which Pyodide version should I target?

Pin a single version per deployment with pyodide-version in wybthon.toml. Wybthon requires Pyodide 314 or newer (Python 3.14). Building with the same Python version as the runtime also lets wyb build ship precompiled bytecode.

How do I install Python packages from PyPI?

Use micropip inside Pyodide:

import micropip


async def setup():
    await micropip.install("httpx")

The package must be pure Python or available as a Pyodide-compatible wheel. See the Pyodide guide for details.

How do I call a JavaScript API from Python?

Import names from the js module yourself (Wybthon doesn't re-export it):

from js import fetch, window

window.alert("hello!")


async def load_users():
    response = await fetch("/api/users")
    return await response.json()

Convert Python objects with pyodide.ffi.to_js(...) when handing them to JS APIs that expect plain objects. For DOM nodes Wybthon rendered, prefer Ref and Element over document.querySelector.

Building and shipping apps

Do I need a bundler or a build step?

There's no JavaScript bundler, but there is a build step. wyb build packages Wybthon and your application into archives with a generated bootstrap, prerenders the routes you list, and turns dev mode off; any static host can serve the result. wyb dev runs the same build in development mode and reloads on change. See the deployment guide.

Can I lazy-load route components?

Yes; see lazy. It's backed by an async memo, so it integrates with Loading for declarative loading UIs and with Errored for load failures, and each lazy component has a .preload() method for warming the cache early.

Components and props

How do I declare a component's props?

As the component function's parameters, with ordinary annotations and defaults. Reading a parameter returns the parent's current value, tracked, as reading a prop does in Solid:

from collections.abc import Callable

from wybthon import component, html


@component
def SaveButton(label: str = "Save", on_save: Callable[[], None] | None = None):
    return html(t"<button onclick={on_save}>{label}</button>")

Wybthon's compiler rewrites every read of a parameter inside an @component body, so {label} in the template is a getter, and the text updates when the parent passes an expression that changes. A handler, memo, or effect that reads a parameter gets the latest value too. Only a read at the top level of the body, such as text = label.upper(), reads once. Parameters are read-only, so assigning to one is a compile-time SyntaxError. A component with no inputs takes no parameters. See Authoring patterns.

How do I pass a callback to a component?

Annotate the parameter as a callable, such as on_save: Callable[[], None] | None = None. Reading on_save returns the function exactly as the parent passed it. Parameters with other annotations (or none) unwrap accessors and zero-argument functions on read, so a callback annotated Any would be called by the read itself.

How do I accept extra attributes and forward them?

Add a **rest parameter (any name). It collects the props the component doesn't declare as a reactive, read-only view that you can spread onto an element:

from typing import Any

from wybthon import component, html


@component
def Button(label: str, **attrs: Any):
    return html(t"<button {attrs}>{label}</button>")

omit and merge work on these views, too: omit(attrs, "title"), merge({"type": "button"}, attrs).

Why does my type checker reject prop(0) or prop(default=0)?

prop takes one keyword argument, default_factory=. Most parameters don't need it: write an ordinary default (count: int = 0). For a mutable value, use prop(default_factory=list), which runs once per component instance: def TagList(tags: list[str] = prop(default_factory=list)).

How do I pass children?

Declare a children parameter, annotated with Children (children: Children = None), and place {children} in the template. Callers nest markup inside a component tag, <{Card} title="Hi"><p>Body</p></{Card}>, or pass it with item syntax, Card(title="Hi")[html(t"<p>Body</p>")], or the children= keyword. Positional arguments aren't children: they bind to parameters as in any Python call, so Card("Hi") is Card(title="Hi").

How do I give a component a key?

Components don't take key=, as in Solid. To remount a component when a value changes, show it with a keyed Show: {Show(doc_id(), lambda id: DocumentView(doc_id=id), keyed=True)}. For lists, use For, which keys rows for you.

Is the <{Card}> tag form type-checked?

Not by a type checker on its own, which can't see inside a template string. wyb check type-checks tag props by checking each <{Card} title=...> as a Card(title=...) call, and dev mode checks a tag's props when it runs, like any component call. You can also call the component inside an interpolation: {Card(title=user().name)} is checked against Card's signature like any other call, and the compiler still passes title as a getter, so it stays reactive.

Do I need a mypy plugin?

No. Pyright, Pylance, and mypy see an @component as the function itself, returning a Node, so a call is checked against the function's own signature, and errors name the component. Under mypy --strict, annotate component functions -> Node. See the typing guide.

Where are the router and forms?

The core lives in wybthon; the router, forms, virtual lists, and scheduling helpers live in their own modules. Import them from wybthon.router, wybthon.forms, wybthon.virtual, and wybthon.scheduling. Links are plain <a href> elements, as in Solid Router 2.0:

from wybthon.forms import bind_text, form_state
from wybthon.router import Route, create_router, navigate, use_link_state

Reactivity

Why didn't my component re-run after a signal changed?

Because components run once by design. A read in the component body captures the value at setup time. To stay reactive, read it in the template, where the compiler turns the expression into a getter (<span>{count()} items</span>, <h2>{title.upper()}</h2>), or derive it with create_memo. In dev mode Wybthon warns when a signal, memo, or prop is read at the top level of a component body; use untrack (create_signal(untrack(lambda: initial))) when a one-time read is what you want.

Why does my signal still show the old value right after I set it?

Writes are staged. set_count(1) records the new value, and count() keeps returning the committed value until the next flush: a browser microtask, the end of an event handler, or an explicit flush. Functional updates see the staged value, so set_count(lambda n: n + 1) twice in one handler adds two. In tests and plain scripts, call flush() after your writes before asserting.

How do I batch multiple signal updates?

You don't need to; everything batches. Consecutive writes in one handler (or one synchronous block) coalesce into a single flush, so an effect that reads both fields runs once:

set_first("Ada")
set_last("Lovelace")
flush()  # the name effect runs once, not twice

There is no batch() function.

Why didn't my effect run when I created it?

create_effect runs its first time on the next flush, after the DOM has been committed, so an effect created in a component body sees the mounted DOM. If you need code to run immediately during setup, just run it; if you need something after mount, use on_settled. create_render_effect runs immediately, but it's meant for rendering primitives.

How do I fetch data?

Write an async def and pass it to create_memo. Reads before the first value raise NotReadyError, which the nearest Loading boundary turns into fallback UI; later refetches run as transitions that hold the dependent UI on the previous state until the new value lands. Use is_pending for a refresh hint, latest to peek without suspending, and refresh or resolve to drive it imperatively. Mutations go through action, optionally with create_optimistic for instant UI.

How do I highlight the selected row without re-running every row?

Use a projection keyed by the selection. Each row reads only its own key, so a change notifies the old and new rows:

from wybthon import create_projection, create_signal

selected, set_selected = create_signal(None)
is_selected = create_projection(lambda: {} if selected() is None else {selected(): True})
# In a row: html(t"<tr class={'active' if is_selected.get(row_id) else ''}>...</tr>")
Why don't I see dev warnings in production?

wyb build turns dev mode off before your application imports, so production builds skip development checks and warnings. wyb dev keeps them on. Check the mode with is_dev_mode().

Next steps