FastUI
Build web UIs with Python decorators, compile to HTML, zero JavaScript required.
Documentation: https://fastui2.readthedocs.io/en/latest/
Source Code: https://github.com/ndugram/fastui2
FastUI is a modern server-rendered UI library for Python. It brings a decorator-based API — similar to FastAPI, but for building HTML pages — with Pydantic-validated components, URL routing, server-side actions, and a built-in Swagger UI.
The key features are:
- Fast: components compile directly to HTML, no template engine overhead. Built-in hot reload for development.
- Simple: define pages as decorated Python functions, return component lists, no HTML templates.
- Typed: full type annotations throughout; all components are Pydantic-validated models with strict validation.
- Zero JS: everything compiles to plain HTML. Buttons with server actions use a lightweight POST mechanism.
- Routed: URL patterns with typed parameters (
/user/{id:int},/post/{year:int}/{slug}). - Interactive: built-in Swagger UI via
/docsto browse and test page routes in the browser. - Extensible: custom CSS, external stylesheets, inline styles, component protocol for custom components.
Requirements¶
Python 3.10+
FastUI stands on the shoulders of giants:
pydantic— component model validation and serialization.annotated-doc— parameter documentation viaAnnotated[type, Doc("...")].
Installation¶
Example¶
Create it¶
Create a file main.py:
from fastui import App, ui
app = App()
@app.page("/")
def home():
return [
ui.heading("FastUI", level=1),
ui.text("Build UIs with Python. No JavaScript required."),
ui.button("About", on_click="/about"),
]
@app.page("/about")
def about():
return [
ui.heading("About", level=1),
ui.text("FastUI compiles Pydantic components to HTML."),
ui.link("Back", url="/"),
]
if __name__ == "__main__":
app.run()
Run it¶
Check it¶
Open http://127.0.0.1:8000 in your browser. You will see a page with a heading, text, and a button.
Interactive API docs¶
Now go to http://127.0.0.1:8000/docs.
You will see the automatic interactive API documentation with all registered routes:

Upgrade the example¶
With typed URL parameters...
Visit `http://127.0.0.1:8000/user/42`. The `id` parameter is automatically converted to `int`.With server actions...
When `on_click` receives a callable, the framework registers it as a POST endpoint.With custom CSS...
With OpenAPI tags...
Tags appear as a filter in the Swagger UI header.Next Steps¶
Now you know the basics. Continue learning:
- First Steps — detailed walkthrough
- Components — all built-in components
- Routing — URL patterns
- Server Actions — POST handlers
- Reference — complete API reference
FAQ¶
- Why would I use FastUI instead of Flask + Jinja2? FastUI eliminates the template layer — you write UIs entirely in Python without HTML files.
- Why would I use FastUI instead of Streamlit? FastUI gives you explicit control over routing, URL parameters, and page structure. Streamlit is script-based and re-runs everything on every interaction.
- Does FastUI support async? Not yet. Async support is planned.
- Can I write my own components? Yes. Any object with a
to_html()method satisfies theComponentprotocol. - Is FastUI production-ready? FastUI is in early development (v0.1.0). The API may change. Suitable for internal tools and prototypes.