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, HTeaPot, adapters
from HTeaLeaf.Elements import div, h3, button

app = HTeaPot(adapters.WSGI)
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)),
    )

application = app.wsgi_app

if __name__ == "__main__":
    from wsgiref.simple_server import make_server
    with make_server("", 8000, application) as server:
        print("Serving at http://127.0.0.1:8000")
        server.serve_forever()

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

@js
def greet(event):
    console.log("hello from Python-compiled JS!")

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

🗺️ 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.3.4.tar.gz (21.5 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.3.4-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: htealeaf-0.3.4.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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.3.4.tar.gz
Algorithm Hash digest
SHA256 67c4d1036622a79062498c332d0d335f197e79bd290c9ddad34d47f30326fde5
MD5 9be049fd902e78ebf91d2cf85275d8fa
BLAKE2b-256 fa4474e8cbd9d698579f2b44e8f41cd9f3ba57e43edc4c49ad56cc57a2f0722e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: htealeaf-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 25.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 aa79cdea1f1ceefdeb34512f86a5b2a8a6e8f89a183dffb54b62cbfaadc206bd
MD5 a252213718b304dfa45fce4172b967ec
BLAKE2b-256 5def528321fc318c1ba9b7eb108dc9973ac311cf2a4d23ae4106aafa665f9950

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