Skip to main content

Declarative SSR Framework

Project description

🍃 HTeaLeaf

HTeaLeaf is a declarative web framework for Python — build dynamic, reactive web apps using pure Python, without writing templates or frontend JavaScript manually.

⚠️ Beta — HTeaLeaf is usable and the core API is stable, but you may encounter performance issues or unexpected bugs. Not recommended for production yet. Feedback and bug reports are very welcome.


✨ Overview

HTeaLeaf merges ideas from modern frontend frameworks (React, Svelte, SolidJS) with the simplicity of Python web servers.

You declare HTML directly in Python, manage reactive state via Store objects, and HTeaLeaf takes care of keeping everything in sync automatically.


🚀 Quick Example

from htealeaf import Store, SuperStore, HTeaLeaf
from htealeaf.elements import div, h3, button

app = HTeaLeaf()
SuperStore(app)

counter = Store({"count": 0})

@app.route("/")
def home():
    return div(
        button("-").attr(onclick=counter.js.update("count", -1)),
        h3(counter.react("count")),
        button("+").attr(onclick=counter.js.update("count", 1)),
    )

The class HTeaLeaf is the app and the entrypoint of ASGI. Next run

$ uvicorn my_app:app

Visit http://127.0.0.1:8000 a fully reactive counter, zero JavaScript written by hand.

You can also write client-side logic directly in Python using the @js decorator, and HTeaLeaf will compile it to JavaScript automatically:

from htealeaf.JS import js

@app.route("/hi")
def say_hi():
    @js
    def greet(event):
        console.log("hello from Python-compiled JS!")
    
    return button("Click me").attr(onclick=greet)

✨ Key Features

  • Declarative HTML: build DOM trees with a fluent Python DSL, no templates needed
  • Reactive server state: Store objects stay in sync with the UI automatically
  • Local route state: use_state() for state scoped to a single route
  • Python → JS transpilation: write client-side logic in Python with @js; HTeaLeaf compiles it
  • Session support: per-user state with AuthStore and cookies

📦 Installation

pip install htealeaf

or

uv add htealeaf

🗺️ Roadmap

  • Declarative HTML DSL
  • Path-based routing
  • Server-side reactive state (Store, AuthStore)
  • Python → JavaScript transpiler
  • Local route state (use_state())
  • Session support
  • Client-side-only state (no server round-trip)
  • Render optimisation
  • Persistent Store backends (Redis, SQL, …)
  • Async first architecture
  • CLI
  • Build system to static assets

📖 Documentation

Full documentation is available in the wiki.


🤝 Ecosystem

HTeaLeaf is part of a tea-themed open-source ecosystem by @Az107:

Project Language Description
HTeaPot Rust HTTP server — plays on HTTP 418 "I'm a teapot"
HTeaLeaf Python This framework — SSR with reactive state and JS transpilation
Cafetera Rust API mocker for testing, built on top of HTeaPot

License

MIT License © 2026 — HTeaLeaf Framework. Made with 🍃 and Python.

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

htealeaf-0.4.0.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

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

htealeaf-0.4.0-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file htealeaf-0.4.0.tar.gz.

File metadata

  • Download URL: htealeaf-0.4.0.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for htealeaf-0.4.0.tar.gz
Algorithm Hash digest
SHA256 a3ac42a644add428e85634c18c56e34ea1627bc67bf29b3d80374c8548abf1fc
MD5 8c7852b1b8b4c6317337f37b854196ae
BLAKE2b-256 897d5f3d2d05cf73d6ae85ef6fcc9792c234dc968335db9c2b8b7fbebdf27060

See more details on using hashes here.

File details

Details for the file htealeaf-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: htealeaf-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 31.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for htealeaf-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0264b833198ad9aede97786fa6a91a173066ff89b49caa3f16677c10bedcc45b
MD5 38278520a8248cb7526e2f3f8a7cb06b
BLAKE2b-256 d83b230649528775b109d76f6d97dd77257946ac96f5ae8e6fef86bff9d10417

See more details on using hashes here.

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