gitmyhub

fasthtml

Jupyter Notebook ★ 7.0k updated 5d ago

The fastest way to create an HTML app

A Python library for building interactive web pages without writing HTML or JavaScript, you write Python functions that generate web pages, and HTMX handles live updates without full reloads.

PythonHTMXpipsetup: easycomplexity 2/5

FastHTML is a Python library for building web applications. The core idea is that your entire app, including the HTML it produces and the server-side logic, lives in a single Python file. You do not write HTML templates separately or learn a special templating language. Instead, you call Python functions that map directly to HTML elements, and the library turns them into a real webpage.

Interactivity works through HTMX, a library that lets the server send back small snippets of HTML in response to user actions. In the FastHTML approach, when a user clicks a button, the server returns just the piece of the page that needs to change, and HTMX swaps it in without a full page reload. The README includes a short example showing how a two-route Python file can produce a clickable page that updates its own text.

Installation is a single pip command. A minimal app is a handful of lines: import FastHTML, define routes using Python decorators, return HTML-producing function calls from each route, and run the built-in server. The README walks through this step by step and links to a one-hour introductory video.

Because FastHTML is newer than most AI coding assistants were trained on, the project provides a plain-text file at fastht.ml/docs/llms-ctx.txt that teaches tools like Cursor or Claude how to use the framework. You can point your AI assistant at that file and it will give more accurate answers about FastHTML than it would otherwise.

Beyond the basics, the project links to a gallery of components (chat bubbles, infinite scroll, click-to-edit patterns), community tutorials, and a Discord server. The documentation notes that not all features are documented yet and that you may need to read source notebooks to understand more advanced usage. The README also lists similar projects in Go, Clojure, Haskell, and other languages for developers curious about the same HTML-over-the-wire approach in different ecosystems.

Where it fits