Skip to main content

Modern HTML generation in Python, inspired by FastHTML

Project description

StarHTML

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🚀 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
  • 🎯 Type Safety - Full IDE support with autocomplete and error detection

🚀 Quick Start

Installation

pip install starhtml

Your First App

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 .

Contributing

We welcome contributions! Please see our Contributing Guide for details.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

🤝 Community & Support

  • 💬 Discussions: GitHub Discussions - Ask questions, share ideas
  • 🐛 Issues: GitHub Issues - Report bugs, request features
  • 📚 Documentation: API Reference
  • 💡 Examples: Check out the /examples directory for more complex use cases

📄 License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

🙏 Acknowledgments

StarHTML is a respectful fork of FastHTML. We're grateful to the FastHTML team for the excellent foundation.

  • FastHTML - The original framework that inspired StarHTML
  • Datastar - The reactive JavaScript library powering client-side interactions
  • Contributors - Thank you to everyone who has contributed to making StarHTML better

⭐ Star us on GitHub if you find StarHTML useful!

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.5.7.tar.gz (637.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.5.7-py3-none-any.whl (125.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for starhtml-0.5.7.tar.gz
Algorithm Hash digest
SHA256 3b679b360155a11a36a81602d5f305de921fdffc5bf9d340ebc74ca120204eb8
MD5 a6284897e245bb1ee768b35d7d42f9da
BLAKE2b-256 942e81846996961ce1953e25c84febd652ffd6bcabcf3ae265a2d1ab0758ebb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for starhtml-0.5.7.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.5.7-py3-none-any.whl.

File metadata

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

File hashes

Hashes for starhtml-0.5.7-py3-none-any.whl
Algorithm Hash digest
SHA256 9143847562ee272aea933df36c6e0ed1fbc33684aee141e8ed76e45b52cc6359
MD5 fd719af42b390036d4460ad07bf3071c
BLAKE2b-256 8f9fcdd775811e9a17e44ab1bd7aeaead861c8c33df2788e1d6ddf0c01cbe328

See more details on using hashes here.

Provenance

The following attestation bundles were made for starhtml-0.5.7-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