# answerdotai/fasthtml

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/answerdotai-fasthtml).**

6,846 stars · 294 forks · Jupyter Notebook · apache-2.0

## Links

- GitHub: https://github.com/AnswerDotAI/fasthtml
- Homepage: https://www.fastht.ml/docs/
- awesome-repositories: https://awesome-repositories.com/repository/answerdotai-fasthtml.md

## Description

FastHTML is a full-stack Python web framework designed for building interactive web applications using pure Python. It functions as an HTMX integration framework and a Python HTML domain-specific language, allowing developers to generate HTML structures using native objects and functions instead of external templating files.

The framework is distinguished by its native support for real-time bidirectional communication via WebSockets and Server-Sent Events, enabling server-side updates to be pushed to the browser without full page reloads. It further integrates identity management through OAuth provider configurations and secure session tracking.

The project covers a broad range of capabilities, including type-hinted database CRUD operations, decorator-based request routing, and middleware for request interception. Its rendering system supports the generation of SVGs, markdown, and custom HTML components, while the developer experience is rounded out by live reloading and the ability to execute applications within interactive notebook environments.

The framework includes tooling for linking projects and deploying applications to cloud hosting platforms.

## Tags

### User Interface & Experience

- [Functional Tag Wrappers](https://awesome-repositories.com/f/user-interface-experience/html-based-ui-structures/functional-tag-wrappers.md) — Generates HTML structures using function composition and dedicated tag functions instead of external templates.
- [Code-Based HTML Construction](https://awesome-repositories.com/f/user-interface-experience/dynamic-html-generators/code-based-html-construction.md) — Enables the creation of HTML structures using native Python objects and functions, eliminating external templating files. ([source](https://www.fastht.ml/docs/tutorials/by_example.html.md))
- [Partial Page Refreshers](https://awesome-repositories.com/f/user-interface-experience/partial-page-refreshers.md) — Updates specific sections of a page without a full refresh by swapping server-delivered content. ([source](https://www.fastht.ml/docs/tutorials/by_example.html.md))
- [Form Data Binding](https://awesome-repositories.com/f/user-interface-experience/form-data-binding.md) — Implements a mapping strategy that unpacks form body data into typed data objects. ([source](https://www.fastht.ml/docs/ref/concise_guide.html.md))
- [Interactive UI Components](https://awesome-repositories.com/f/user-interface-experience/interactive-ui-components.md) — Facilitates the construction of dynamic UI elements like search bars and infinite scrolling that update without reloads. ([source](https://gallery.fastht.ml/))
- [Reusable UI Components](https://awesome-repositories.com/f/user-interface-experience/reusable-ui-components.md) — Enables the creation of reusable UI elements using functions that map arguments to children and attributes. ([source](https://www.fastht.ml/docs/ref/concise_guide.html.md))

### Web Development

- [Full-Stack Web Frameworks](https://awesome-repositories.com/f/web-development/full-stack-web-frameworks.md) — Functions as a comprehensive framework for building entire web applications with server-side logic and interfaces in pure Python.
- [HTML Domain Specific Languages](https://awesome-repositories.com/f/web-development/html-domain-specific-languages.md) — Provides a Python HTML domain-specific language to generate web user interfaces using native objects and functions instead of templates. ([source](https://www.fastht.ml/docs/explains/explaining_xt_components.html.md))
- [Server-Side Rendering](https://awesome-repositories.com/f/web-development/server-side-rendering.md) — Generates structured web pages and UI components directly from Python code without external templates. ([source](https://cdn.jsdelivr.net/gh/answerdotai/fasthtml@main/README.md))
- [HTMX Integrations](https://awesome-repositories.com/f/web-development/ajax-content-swapping/htmx-integrations.md) — Integrates HTMX to create dynamic user interfaces by swapping HTML fragments over HTTP and WebSockets.
- [Function-to-URL Mappings](https://awesome-repositories.com/f/web-development/api-management-tools/api-development-management/web-apis/administrative-api-endpoints/endpoint-discovery/endpoint-translation-maps/function-to-url-mappings.md) — Links specific HTTP methods and URL paths to Python functions using decorators. ([source](https://www.fastht.ml/docs/explains/routes.html.md))
- [Python Web Frameworks](https://awesome-repositories.com/f/web-development/backend-development/web-frameworks/language-specific-ecosystems/python-web-frameworks.md) — Provides a server-side framework for building interactive web applications using pure Python.
- [Dynamic Fragment Updates](https://awesome-repositories.com/f/web-development/differential-page-update-generation/dynamic-fragment-updates.md) — Updates specific page sections by swapping server-delivered HTML fragments into target elements.
- [Full-Stack Frameworks](https://awesome-repositories.com/f/web-development/full-stack-frameworks.md) — Provides an integrated environment combining routing, session management, OAuth, and database CRUD in a single Python toolkit.
- [Interactive Web Frameworks](https://awesome-repositories.com/f/web-development/interactive-web-frameworks.md) — Enables the creation of dynamic pages that update specific HTML elements in real time without full page reloads.
- [Real-Time Communication](https://awesome-repositories.com/f/web-development/real-time-communication.md) — Implements bidirectional communication to update the user interface in real time without reloading the page. ([source](https://www.fastht.ml/docs/ref/concise_guide.html.md))
- [Route Handlers](https://awesome-repositories.com/f/web-development/route-handlers.md) — Maps URL paths to handler functions that return HTML, JSON, or strings to process HTTP requests. ([source](https://www.fastht.ml/docs/ref/handlers.html.md))
- [Decorator-Based Route Mappings](https://awesome-repositories.com/f/web-development/routing-systems/routing/decorator-based-route-mappings.md) — Defines routing configurations by attaching metadata to handler functions using language-level decorators.
- [Application Route Definitions](https://awesome-repositories.com/f/web-development/routing-systems/routing/route-definition-strategies/application-route-definitions.md) — Maps URI paths and HTTP methods to functions that render HTML content or process submitted data. ([source](https://www.fastht.ml/docs/tutorials/e2e.html.md))
- [WebSocket State Synchronization](https://awesome-repositories.com/f/web-development/state-syncing-reactivity/websocket-state-synchronization.md) — Synchronizes application state based on real-time bidirectional communication events via WebSockets.
- [Real-Time Frameworks](https://awesome-repositories.com/f/web-development/web-applications/real-time-frameworks.md) — Ships a web framework with native support for bidirectional communication and real-time server-to-browser updates.
- [Response Header Modifiers](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/http-response-handling/response-metadata-accessors/response-header-modifiers.md) — Utilizes specialized response header modifiers to trigger client-side interface updates via HTMX. ([source](https://www.fastht.ml/docs/ref/concise_guide.html.md))
- [Modular Routing Systems](https://awesome-repositories.com/f/web-development/backend-development/web-frameworks/routing-request-handling/modular-routing-systems.md) — Supports splitting route configurations across multiple files using routers with optional URL prefixes. ([source](https://www.fastht.ml/docs/ref/handlers.html.md))
- [Client-Side Library Integrations](https://awesome-repositories.com/f/web-development/client-side-library-integrations.md) — Allows for the embedding of external JavaScript libraries and custom scripts to add complex browser-side behavior. ([source](https://www.fastht.ml/docs/tutorials/e2e.html.md))
- [Form Data Object Mapping](https://awesome-repositories.com/f/web-development/form-data-object-mapping.md) — Captures form input values as structured typed dictionaries or data objects with automatic type conversion. ([source](https://www.fastht.ml/docs/ref/handlers.html.md))
- [Request Parameter Parsers](https://awesome-repositories.com/f/web-development/request-parameter-parsers.md) — Extracts and validates dynamic data from web request paths, query strings, and cookies. ([source](https://www.fastht.ml/docs/tutorials/by_example.html.md))
- [Response Handlers](https://awesome-repositories.com/f/web-development/response-handlers.md) — Manages the output phase of the request cycle by returning components, JSON, or standard HTTP responses. ([source](https://www.fastht.ml/docs/ref/concise_guide.html.md))
- [Response Rendering](https://awesome-repositories.com/f/web-development/response-rendering.md) — Allows route handlers to return various content formats, including HTML components, JSON, and standard HTTP responses. ([source](https://www.fastht.ml/docs/llms-ctx.txt))
- [Route Generators](https://awesome-repositories.com/f/web-development/route-generators.md) — Generates URL paths and dynamic query parameters based on route handler functions. ([source](https://www.fastht.ml/docs/llms-ctx.txt))
- [Route Organization](https://awesome-repositories.com/f/web-development/route-organization.md) — Allows distributing route definitions across multiple files using a dedicated router to maintain project structure. ([source](https://www.fastht.ml/docs/llms-ctx.txt))
- [Route Path Generators](https://awesome-repositories.com/f/web-development/routing-systems/routing/parameter-handling-utilities/path-parameter-converters/route-path-generators.md) — Implements the ability to convert handler functions into URL paths to avoid hardcoding route strings. ([source](https://www.fastht.ml/docs/ref/concise_guide.html.md))
- [URL Generators](https://awesome-repositories.com/f/web-development/url-generators.md) — Provides utilities for programmatically constructing absolute or relative URLs for named routes. ([source](https://www.fastht.ml/docs/ref/handlers.html.md))

### Data & Databases

- [Application State Management](https://awesome-repositories.com/f/data-databases/application-state-management.md) — Integrates databases and uses Python dataclasses to store and retrieve application state. ([source](https://www.fastht.ml/docs/tutorials/e2e.html.md))
- [Class-Based Schema Mappings](https://awesome-repositories.com/f/data-databases/class-based-schema-mappings.md) — Maps database tables to native classes to perform CRUD operations through a high-level object interface.
- [CRUD Operations](https://awesome-repositories.com/f/data-databases/crud-operations.md) — Interacts with databases using a type-hinted class system and high-level data manipulation methods. ([source](https://www.fastht.ml/docs/ref/concise_guide.html.md))
- [Type-Hinted Database Interfaces](https://awesome-repositories.com/f/data-databases/database-query-interfaces/type-hinted-database-interfaces.md) — Provides a high-level interface for database operations using Python classes and type hints. ([source](https://www.fastht.ml/docs/llms-ctx.txt))
- [Database Record Querying](https://awesome-repositories.com/f/data-databases/database-record-querying.md) — Retrieves records from tables with support for filtering, ordering, limits, and offsets. ([source](https://www.fastht.ml/docs/explains/minidataapi.html.md))
- [Record Deletion](https://awesome-repositories.com/f/data-databases/record-deletion.md) — Removes records from the database using primary keys or compound keys. ([source](https://www.fastht.ml/docs/explains/minidataapi.html.md))
- [Record Insertion](https://awesome-repositories.com/f/data-databases/record-insertion.md) — Adds new entries to tables using classes, dictionaries, or keyword arguments. ([source](https://www.fastht.ml/docs/explains/minidataapi.html.md))
- [Record Updating](https://awesome-repositories.com/f/data-databases/record-updating.md) — Modifies existing records identified by their primary key using class instances or dictionaries. ([source](https://www.fastht.ml/docs/explains/minidataapi.html.md))
- [Single Record Retrievers](https://awesome-repositories.com/f/data-databases/single-record-retrievers.md) — Fetches specific records by their primary or compound key using square bracket indexing. ([source](https://www.fastht.ml/docs/explains/minidataapi.html.md))
- [Table Definitions](https://awesome-repositories.com/f/data-databases/table-definitions.md) — Creates database tables based on Python classes with support for custom primary keys and schema transformations. ([source](https://www.fastht.ml/docs/explains/minidataapi.html.md))
- [Record](https://awesome-repositories.com/f/data-databases/table-specifications/existence-verification/record.md) — Verifies if a record with a specific primary key exists in a table using a membership operator. ([source](https://www.fastht.ml/docs/explains/minidataapi.html.md))
- [Persistent Filters](https://awesome-repositories.com/f/data-databases/data-query-filters/persistent-filters.md) — Implements persistent filters on tables to automatically restrict database queries to records matching specific criteria. ([source](https://www.fastht.ml/docs/explains/minidataapi.html.md))

### Networking & Communication

- [Real-Time Web Communication](https://awesome-repositories.com/f/networking-communication/real-time-web-communication.md) — Implements bidirectional data exchange and live server-side updates using WebSockets.
- [Bidirectional Protocol Communication](https://awesome-repositories.com/f/networking-communication/bidirectional-protocol-communication.md) — Manages bidirectional socket connections to perform out-of-band content swaps for dynamic interfaces. ([source](https://www.fastht.ml/docs/llms-ctx.txt))
- [Real-Time Messaging](https://awesome-repositories.com/f/networking-communication/real-time-messaging.md) — Supports multi-user messaging and live data updates through persistent bidirectional WebSocket connections. ([source](https://gallery.fastht.ml/))
- [Server-Sent Events](https://awesome-repositories.com/f/networking-communication/server-sent-events.md) — Provides server-sent events to push real-time updates from the server to the client via a persistent stream. ([source](https://www.fastht.ml/docs/ref/concise_guide.html.md))

### Programming Languages & Runtimes

- [HTML Domain-Specific Languages](https://awesome-repositories.com/f/programming-languages-runtimes/html-domain-specific-languages.md) — Implements a Python HTML DSL that represents elements and attributes as native Python objects instead of external templates.
- [Request Parameter Parsing](https://awesome-repositories.com/f/programming-languages-runtimes/type-annotations/request-parameter-parsing.md) — Extracts URL paths and query strings as type-annotated function arguments for simplified retrieval. ([source](https://www.fastht.ml/docs/ref/handlers.html.md))

### Security & Cryptography

- [OAuth Provider Integrations](https://awesome-repositories.com/f/security-cryptography/identity-access-management/identity-management/identity-service-providers/oauth-provider-integrations.md) — Integrates external identity providers to handle user login and access control using standardized OAuth flows. ([source](https://www.fastht.ml/docs/explains/oauth.html.md))
- [Session State Persistence](https://awesome-repositories.com/f/security-cryptography/identity-authentication/identity-based-authentication/session-state-persistence.md) — Maintains authenticated user identities and application state across multiple HTTP requests using signed session stores.
- [OAuth Providers](https://awesome-repositories.com/f/security-cryptography/oauth-providers.md) — Provides pre-built scaffolding and clients to connect authentication services like Google, GitHub, and Discord. ([source](https://www.fastht.ml/docs/llms-ctx.txt))
- [Secure Session Management](https://awesome-repositories.com/f/security-cryptography/secure-session-management.md) — Stores secure, signed data in the browser to maintain user identity across multiple requests. ([source](https://www.fastht.ml/docs/tutorials/by_example.html.md))
- [OAuth Providers](https://awesome-repositories.com/f/security-cryptography/identity-access-management/authentication-strategies/user-facing-login-methods/oauth-identity-providers/oauth-providers.md) — Integrates external identity providers via OAuth to manage user logins and secure session access.
- [Session State Injection](https://awesome-repositories.com/f/security-cryptography/identity-based-access-control/credential-based-access-controls/session-based-access-controls/session-state-injection.md) — Exposes session middleware via route handler parameters to track and manage user state across requests. ([source](https://www.fastht.ml/docs/ref/concise_guide.html.md))
- [Request Authentication Middleware](https://awesome-repositories.com/f/security-cryptography/request-authentication-middleware.md) — Uses decorators to apply middleware to specific endpoints for session validation and access control. ([source](https://www.fastht.ml/docs/explains/routes.html.md))
- [OAuth Session Tracking](https://awesome-repositories.com/f/security-cryptography/session-authentication/oauth-session-tracking.md) — Monitors authenticated users through unique identifiers and metadata to customize content or restrict access. ([source](https://www.fastht.ml/docs/explains/oauth.html.md))
- [WebSocket Session Synchronization](https://awesome-repositories.com/f/security-cryptography/session-cookie-handlers/cross-subdomain-session-sharing/websocket-session-synchronization.md) — Provides a mechanism to access and modify shared session data consistently across both HTTP and WebSocket connections. ([source](https://www.fastht.ml/docs/explains/websockets.html.md))

### Development Tools & Productivity

- [Development Refreshers](https://awesome-repositories.com/f/development-tools-productivity/development-refreshers.md) — Watches for file system changes and automatically refreshes the web browser to display updates. ([source](https://www.fastht.ml/docs/ref/live_reload.html.md))
- [Live Reloading Environments](https://awesome-repositories.com/f/development-tools-productivity/live-reloading-environments.md) — Implements a development mode that monitors source code changes and automatically refreshes the server and browser. ([source](https://www.fastht.ml/docs/llms-ctx.txt))

### Software Engineering & Architecture

- [Request Interception Middleware](https://awesome-repositories.com/f/software-engineering-architecture/request-interception-middleware.md) — Provides middleware to intercept requests before they reach route handlers for authentication and authorization. ([source](https://www.fastht.ml/docs/ref/concise_guide.html.md))
- [Request Middleware](https://awesome-repositories.com/f/software-engineering-architecture/request-middleware.md) — Provides middleware components for intercepting and processing request-response cycles for cross-cutting concerns.
- [Request Parameter Type-Hinting](https://awesome-repositories.com/f/software-engineering-architecture/type-hint-based-schema-definitions/request-parameter-type-hinting.md) — Extracts URL paths and query parameters into typed function arguments using language-level type annotations.

### Part of an Awesome List

- [Web Frameworks](https://awesome-repositories.com/f/awesome-lists/devtools/web-frameworks.md) — Listed in the “Web Frameworks” section of the Awesome Python awesome list.
