Modern HTML generation in Python, inspired by FastHTML
Project description
StarHTML
A Python-first hypermedia framework, forked from FastHTML. Uses Datastar instead of HTMX for the same hypermedia-driven approach with a different flavor.
✨ 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.
- 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
🤝 Community & Support
- 💬 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
📄 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file starhtml-0.3.0.tar.gz.
File metadata
- Download URL: starhtml-0.3.0.tar.gz
- Upload date:
- Size: 530.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa41a67184ac57038069eab173c956cc52a729b8b46d4a639d7a2663f0e5360d
|
|
| MD5 |
5cb3f3c90c3b1deb8e5bde93608be268
|
|
| BLAKE2b-256 |
65eccc033ba56dba97f55387d27065da6d7d8c87b22d874be3fea11c485c0a6c
|
Provenance
The following attestation bundles were made for starhtml-0.3.0.tar.gz:
Publisher:
release.yml on banditburai/starHTML
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
starhtml-0.3.0.tar.gz -
Subject digest:
aa41a67184ac57038069eab173c956cc52a729b8b46d4a639d7a2663f0e5360d - Sigstore transparency entry: 601362886
- Sigstore integration time:
-
Permalink:
banditburai/starHTML@69e87dc11c242d4148cd3d09e33f2131f8f0ca07 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/banditburai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@69e87dc11c242d4148cd3d09e33f2131f8f0ca07 -
Trigger Event:
push
-
Statement type:
File details
Details for the file starhtml-0.3.0-py3-none-any.whl.
File metadata
- Download URL: starhtml-0.3.0-py3-none-any.whl
- Upload date:
- Size: 97.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b375c7da389e1477553dbe6c4f53c27921a784dd4fd99b99d7fe421ceab7922
|
|
| MD5 |
684ac43e6f5ac6264345cf87c05b604f
|
|
| BLAKE2b-256 |
0d31324ed6f515b6bc5d4afa6828a252614628231c86416dcc74bce2deff235d
|
Provenance
The following attestation bundles were made for starhtml-0.3.0-py3-none-any.whl:
Publisher:
release.yml on banditburai/starHTML
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
starhtml-0.3.0-py3-none-any.whl -
Subject digest:
0b375c7da389e1477553dbe6c4f53c27921a784dd4fd99b99d7fe421ceab7922 - Sigstore transparency entry: 601362888
- Sigstore integration time:
-
Permalink:
banditburai/starHTML@69e87dc11c242d4148cd3d09e33f2131f8f0ca07 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/banditburai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@69e87dc11c242d4148cd3d09e33f2131f8f0ca07 -
Trigger Event:
push
-
Statement type: