Registry / web-framework / python-fasthtml

python-fasthtml

JSON →
library0.14.12pypypiunverified

FastHTML is a lightweight and performant Python library designed for building dynamic HTML web applications with minimal code. It leverages ASGI for high performance and integrates well with technologies like HTMX for interactive user experiences. As of version 0.13.3, it is under active development with frequent minor releases.

pip install fasthtml uvicorn
INSTALL
IMPORT
SIG · PYTHON-FASTHTML
P
python-fasthtml
web-frameworkpythonv0.14.12
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FastHTML
from fasthtml import FastHTML
HTML
from fasthtml.common import HTML
H1
from fasthtml.common import H1
P
from fasthtml.common import P
A
from fasthtml.common import A
Capture
from fasthtml.components import Capture

This quickstart creates a simple FastHTML application that displays a clickable counter. It leverages HTMX to update the counter value on the page without a full page reload, demonstrating FastHTML's strength in building interactive UIs.

from fasthtml.common import * from uvicorn import run app = FastHTML() # Global counter for demonstration counter_val = 0 @app.get('/') def home(): return ( Title('FastHTML Counter with HTMX'), H1('Click Counter'), P( 'Count: ', A( counter_val, id='count', _hx_get='/count', _hx_swap='outerHTML', _hx_trigger='click' ) ) ) @app.get('/count') def count_update(): global counter_val counter_val += 1 return A( counter_val, id='count', _hx_get='/count', _hx_swap='outerHTML', _hx_trigger='click' ) if __name__ == '__main__': # Run with uvicorn: uvicorn main:app --reload run(app, port=8000)
fasthtml --version
Debug
Known issues
gotchaFastHTML implicitly renders HTML components returned from route functions. If you need to return a custom Starlette/FastAPI `Response` object (e.g., `RedirectResponse`, `JSONResponse`), ensure it's explicitly imported and returned, as FastHTML's auto-rendering will be bypassed.
fix
For explicit response types, import and return `from starlette.responses import JSONResponse` or `RedirectResponse` directly. For HTML, ensure your route returns FastHTML's `HTML` components or a string.
affects: All versions
gotchaHandling complex form data, especially file uploads or multipart forms, might require using the `Capture` component. While simple form parameters are automatically injected into route function arguments, accessing raw request bodies or specific file metadata is less direct.
fix
For multipart forms and file uploads, use `from fasthtml.components import Capture` and pass `request: Capture` as an argument to your route function to access `request.form()` or `request.files()`.
affects: All versions
breakingFastHTML is actively developed and currently below version 1.0. Minor version updates may introduce breaking changes to the API, internal structures, or default behaviors without a major version increment. Always review release notes carefully when upgrading.
fix
Consult the GitHub release notes (`https://github.com/AnswerDotAI/fasthtml/releases`) for each upgrade. Pin specific minor versions in your `requirements.txt` to control upgrades (e.g., `fasthtml~=0.13.0`).
affects: < 1.0.0
gotchaIntegrating custom Starlette middleware or lifespan events (`on_startup`, `on_shutdown`) requires understanding FastHTML's wrappers. Direct use of `app.add_middleware` might be less idiomatic than expected, and lifespan events are managed via a dedicated `Lifespan` class.
fix
For middleware, use `from starlette.middleware import Middleware` and pass them to the `FastHTML` constructor. For lifespan, refer to FastHTML's documentation on its `Lifespan` class and `on_event` decorator introduced in recent versions.
affects: All versions
Upgrade
Version history
0.14.12latest on PyPI · released Aug 19, 2026
Audit
Dependencies
uvicornrequiredASGI server required to run FastHTML applications.
starletterequiredFastHTML is built on Starlette and inherits its ASGI capabilities. Usually handled as a transitive dependency.
Agent activity
12 hits · last 30 days
node
10
Resources
python-fasthtml — pip install python-fasthtml · libregistry