Skip to main content

Modern HTML generation in Python, inspired by FastHTML

Project description

StarHTML — Python Web Framework

StarUI — Python Component Library

PyPI Version License

A Python-first hypermedia framework, forked from FastHTML. Uses Datastar instead of HTMX for the same hypermedia-driven approach with a different flavor.

Documentation · UI Components · Quick Start · Community · Issues

Key Features

  • Python-First — Write reactive UIs using Python syntax with type safety and IDE support
  • Reactive Signals — Hypermedia approach with data-attribute-powered client-side reactivity where needed
  • Server-Sent Events — Built-in SSE support for real-time server interactions
  • Framework Agnostic — Works with any CSS framework (Tailwind, DaisyUI)
  • JavaScript Escape Hatch — Drop into raw JavaScript when needed for complex interactions

Quick Start

pip install starhtml
from starhtml import *

app, rt = star_app()

@rt('/')
def home():
    return Div(
        H1("StarHTML Demo"),

        # Define reactive state with signals
        Div(
            (counter := Signal("counter", 0)),  # Python-first signal definition

            # Reactive UI that updates automatically
            P("Count: ", Span(data_text=counter)),
            Button("+", data_on_click=counter.add(1)),
            Button("Reset", data_on_click=counter.set(0)),

            # Conditional styling
            data_class_active=counter > 0
        ),

        # Server-side interactions
        Button("Load Data", data_on_click=get("/api/data")),
        Div(id="content")
    )

@rt('/api/data')
def api_data():
    return Div("Data loaded from server!", id="content")

serve()

Run with python app.py and visit http://localhost:5001.

What's Different?

FastHTML StarHTML
HTMX for server interactions Datastar for reactive UI
Built with nbdev notebooks Standard Python modules
Multiple JS extensions Single reactive framework
WebSockets for real-time SSE for real-time

Development

git clone https://github.com/banditburai/starhtml.git
cd starhtml
uv sync  # or pip install -e ".[dev]"
pytest && ruff check .

Contributions welcome — see CONTRIBUTING.md.

Acknowledgments

StarHTML is a fork of FastHTML. Built on Datastar for client-side reactivity.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

starhtml-0.6.1.tar.gz (798.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

starhtml-0.6.1-py3-none-any.whl (155.2 kB view details)

Uploaded Python 3

File details

Details for the file starhtml-0.6.1.tar.gz.

File metadata

  • Download URL: starhtml-0.6.1.tar.gz
  • Upload date:
  • Size: 798.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for starhtml-0.6.1.tar.gz
Algorithm Hash digest
SHA256 f008302a3639c66d11518c5cc63558928b10407cd7606a23ef5d8e105c8a0321
MD5 ea91ef98518eddf9dcca2050842b8db4
BLAKE2b-256 13b2625b57e5d1588a5714c7cb26c71410b286b43c968a57d5511501444d5b06

See more details on using hashes here.

Provenance

The following attestation bundles were made for starhtml-0.6.1.tar.gz:

Publisher: release.yml on banditburai/starHTML

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file starhtml-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: starhtml-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 155.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for starhtml-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 38bd6cd98c0a22f77cc17a9c2fb721708fc8bb6b8ea293e5edc118f19b8a3d61
MD5 d7fd907dec16ba93f73e69270b650eac
BLAKE2b-256 18c7cf9e36ed8a0b672653c8d62f1e48e42bc104eb0999bc2dee4ef7de004847

See more details on using hashes here.

Provenance

The following attestation bundles were made for starhtml-0.6.1-py3-none-any.whl:

Publisher: release.yml on banditburai/starHTML

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page