A Python-first hypermedia framework, forked from FastHTML. Uses Datastar instead of HTMX for the same hypermedia-driven approach with a different flavor.
- 🐍 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
pip install starhtmlfrom 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.
| 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 |
git clone https://github.com/banditburai/starhtml.git
cd starhtml
uv sync # or pip install -e ".[dev]"
pytest && ruff check .We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- 💬 Discussions: GitHub Discussions - Ask questions, share ideas
- 🐛 Issues: GitHub Issues - Report bugs, request features
- 📚 Documentation: API Reference
- 💡 Examples: Check out the
/examplesdirectory for more complex use cases
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
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!