Skip to main content

Hedron

FastAPI-native, server-rendered interfaces in pure Python.

Typed components · HTMX requests · Alpine.js local behavior · No frontend build

PyPI Python CI Docs Pyright: strict API: Stable License: MIT

Documentation · Quickstart · Showcase · API · Security

Hedron lets FastAPI applications return Python component trees as safe HTML pages and fragments. It adds a typed UI model and progressive interaction without taking away FastAPI routes, dependencies, middleware, lifespan hooks, JSON endpoints, responses, or OpenAPI.

The result is one application with one routing, rendering, security, state, and deployment authority—without a generated frontend project, Node.js toolchain, virtual DOM, or whole-script rerun loop.

Hedron Showcase command center in dark mode

Explore the complete showcase → · View the reproducible source

Package maturity: Stable · Version line documented: 1.0.x

Every command and example below targets the Hedron 1.0 API. Supported Python versions are 3.10–3.14; applications should require the >=1.0.0 stable compatibility floor shown below.

Start in under a minute

The fastest path uses uv:

uvx --from "hedron>=1.0.0" hedron new my-hedron-app
cd my-hedron-app
uv sync
uv run hedron run app:app --reload

Open http://127.0.0.1:8000. The generated project is ordinary Python and includes a complete page, an addressable view, a typed action, built-in styling, and progressive HTTP fallbacks.

Adding Hedron to an existing project is just as direct:

uv add "hedron>=1.0.0" "uvicorn[standard]"
# or: python -m pip install "hedron>=1.0.0" "uvicorn[standard]"

The core model

Hedron deliberately gives each route one clear responsibility:

Role Responsibility Typical result
@app.page Render a complete navigable document A component tree or explicit Page
@app.view Render an independently addressable read fragment A component or fragment tree
@app.action Process an unsafe request and declare its outcome Refresh, redirect, validation, or another typed outcome
from datetime import datetime, timezone

from hedron import Hedron, Heading, Stack, Text, html

app = Hedron(title="Operations", security="standard")


@app.view("/status")
def status():
    stamp = datetime.now(timezone.utc).strftime("%H:%M:%S UTC")
    return html.div(
        Text(f"All systems operational · {stamp}"),
        role="status",
        aria={"live": "polite"},
    )


@app.page("/")
def home():
    return Stack(
        Heading("Operations"),
        status(),
        status.refresh_button("Refresh status"),
    )

Run it with hedron run app:app --reload or uvicorn app:app --reload.

Calling status() composes its initial output into the page. Its route handle also carries the declared endpoint and target policy needed for later fragment refreshes. Hedron rejects requests that attempt to update an undeclared target.

Typed actions

Unsafe requests cross an explicit validation and CSRF boundary:

from typing import Annotated

from pydantic import BaseModel, Field

from hedron import FormBody, Text


class Note(BaseModel):
    message: str = Field(min_length=1, max_length=200)


@app.action("/notes", fallback="/")
def add_note(note: Annotated[Note, FormBody()]):
    save_authorized_note(note)
    return Text("Note saved")


# Compose the native progressive form in any page:
# add_note.form(submit_label="Save note")

Hedron owns request parsing, validation lowering, CSRF integration, and response semantics. Authentication, row authorization, transactions, idempotency, and durable audit records remain application responsibilities.

What you get

Concern Built-in capability
UI composition Application shells, navigation, grids, cards, forms, tables, dialogs, media, status, and accessibility primitives
Interaction Addressable views, typed actions, declared targets, HTMX swaps, out-of-band updates, polling, and ordinary HTTP fallbacks
Styling Responsive built-in themes, light/dark modes, design tokens, recipes, and component styling with no app-authored CSS required
FastAPI integration Dependencies, middleware, lifespan, mounts, responses, JSON routes, OpenAPI, and root-path support
Safety Contextual escaping, typed safe URLs, explicit trusted-HTML boundaries, CSRF profiles, security headers, and conservative caching
Operations Build manifests, diagnostics, generated interaction tests, conformance reports, observability hooks, and deployment checks
Extension Feature packages, component packages, Jinja/HDJ, Web Components, charts, maps, adapters, and a framework-neutral renderer

The built-in theme follows the browser color preference, supports explicit light/dark selection, and collapses application shells and content grids for narrow screens. Custom CSS is optional, not a prerequisite for a finished application.

Browser behavior has clear ownership

Hedron uses two small, complementary runtimes:

Browser-local presentation state       Server interaction and domain state
Alpine.js                               HTMX + FastAPI
disclosures, tabs, menus, focus         requests, fragments, actions, jobs

Alpine state is disposable and reconstructable from rendered HTML. HTMX owns requests, fragment replacement, and declared request lifecycles. Application and domain state stay on the server.

Hedron vendors Alpine.js 3.16.3 as a CSP-compatible, same-origin asset and emits it only when a page needs Alpine behavior. Required plugins are pinned and demand-driven. Use built-in components and typed AlpineAttrs; arbitrary executable Alpine strings are outside the stable authoring API.

Read the HTMX/Alpine ownership guide.

Components are ordinary Python values

from hedron import Card, Heading, SafeUrl, Stack, Text, UrlPurpose, html

summary = Card(
    Stack(
        Heading("Quarterly summary", level=2),
        Text("Revenue increased 18%."),
        html.a(
            "View report",
            href=SafeUrl.parse("/reports/q4", purpose=UrlPurpose.NAVIGATION),
        ),
    )
)

User-controlled strings remain text. HTML and URLs cross explicit trust boundaries, so database, tenant, upload, and generated content cannot silently become executable markup.

Project-owned components are normal Python packages. They can participate in the same theme, asset, accessibility, inspection, and conformance contracts as built-ins.

Use only the packages you need

The stable 1.0 family is intentionally small:

Package Purpose
hedron-core Framework-neutral components, rendering, interaction, and security contracts
hedron FastAPI-native application and authoring facade
hedron-data Bounded data tables, editors, queries, and workspaces
hedron-charts First-party chart specifications, rendering, and adapters
hedron-maps Accessible maps, layers, markers, and URL policies
edron Higher-level class-oriented application authoring

Install coordinated capabilities through extras:

uv add "hedron[data,charts,maps]>=1.0.0"

Other extras activate optional or Beta integrations such as dev, jinja, markdown, auth, native, elements, conformance, notebook, gradio, mcp, and posit. Those packages may release independently; consult the compatibility matrix rather than guessing compatible floors.

Add Hedron to an existing FastAPI application

Hedron can supply UI routes and static assets without replacing application construction:

from fastapi import FastAPI

from hedron import HTML, HedronRouter, Text, hedron_response, mount_hedron_static
from hedron.security.policy import SecurityPolicy

app = FastAPI()
app.state.hedron_security = SecurityPolicy.from_name("standard")
mount_hedron_static(app)

ui = HedronRouter()


@ui.get("/hello", **hedron_response())
def hello():
    return HTML(Text("Hello from Hedron"))


app.include_router(ui)

Read the integration guide for lifespan, assets, root paths, and response behavior. The renderer is framework-neutral, with first-party Beta host adapters for Flask and Django.

Production checklist

Hedron provides secure defaults and inspectable boundaries. Before deployment:

  • Set a strong application-specific session secret; never ship a scaffold fallback.
  • Authenticate users and authorize every protected page, view, action, row, and download.
  • Use shared state, cache, and job backends for multi-worker deployments.
  • Keep tenancy, persistence, transactions, retries, idempotency, and audit storage in application services.
  • Treat user, database, upload, and generated content as untrusted input.
  • Validate proxy trust, root paths, HTTPS, cookies, CSP, artifact paths, and topology-specific behavior with deployment checks.
  • Prefer polling for durable job status unless SSE/WebSocket proxy buffering, timeouts, and backpressure have been verified.

Hedron is not an ORM, identity provider, database, durable job broker, hosted service, or client-side SPA runtime.

Inspect before you ship

# Inspect a trusted application
hedron --app app:app routes
hedron --app app:app components
hedron --app app:app graph

# Run diagnostics and static migration checks
hedron --app app:app check
hedron check --project . --target 1.0 --format sarif

# Build assets and inspect the installed package fleet
hedron --app app:app build
hedron fleet

The CLI also covers component previews, accessibility inspection, security posture, themes, generated interaction tests, conformance, package authoring, and offline upgrade reports.

Hedron or Edron?

Choose Hedron when you want direct component-tree composition, FastAPI-native function routes, host integration, or framework extension points.

Choose Edron when you want a smaller class-oriented API, batteries-included data/chart/map dependencies, familiar dashboard vocabulary, and Streamlit migration tooling. Edron lowers into this same Hedron runtime; it is not a parallel framework.

See the complete application

The Hedron Showcase is a responsive, light/dark operations console built from the same public source linked by the documentation. It covers application chrome, metrics, workflow status, tables, fragment refresh, and a typed action without documentation-only UI or custom application CSS.

For the smallest interaction, use the Hello + Refresh example.

Learn more

License

Hedron is available under the MIT License.

Release files for hedron 1.0.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hedron 1.0.16
File Size Uploaded
hedron-1.0.16.tar.gz 332.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hedron 1.0.16
File Interpreter ABI Platform
hedron-1.0.16-py3-none-any.whl Python 3 none any Details

Total release size: 734.3 kB

Release files / hedron-1.0.16.tar.gz

Download URL hedron-1.0.16.tar.gz
Size 332.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4e11abc2735d57cd516298d87498bd3ff5a1c0dc21ed36c9b1eddbf2b7c2a0ba
BLAKE2b-256 checksum
How to use checksums
7598f641baf429dcf0c7801760843910d6a958dd806c48f340fd30eb73d90a52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / hedron-1.0.16-py3-none-any.whl

Download URL hedron-1.0.16-py3-none-any.whl
Size 402.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8214b30957e8cc76edc4af6cf030fd309cdd77f6a71823007137c1d9fdd34437
BLAKE2b-256 checksum
How to use checksums
260a14f198243f121a5927316c0d5afe553d91b17cd177b9be381f084d0ffc6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.18

2 release files

1.0.17

2 release files

This release

1.0.16 This release

2 release files

1.0.15

2 release files

1.0.14

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.67.0

2 release files

0.66.2

2 release files

0.66.1

2 release files

0.66.0

2 release files

0.65.0

2 release files

0.64.1

2 release files

0.64.0

2 release files

0.63.0

2 release files

0.62.0

2 release files

0.61.0

2 release files

0.60.2

2 release files

0.60.1

2 release files

0.60.0

2 release files

0.59.0

2 release files

0.58.1

2 release files

0.58.0

2 release files

0.57.0

2 release files

0.56.0

2 release files

0.55.0

2 release files

0.54.0

2 release files

0.53.0

2 release files

0.52.0

2 release files

0.51.2

2 release files

0.51.1

2 release files

0.51.0

2 release files

0.50.3

2 release files

0.50.2

2 release files

0.50.1

2 release files

0.50.0

2 release files

0.49.1

2 release files

0.49.0

2 release files

0.48.0

2 release files

0.47.0

2 release files

0.46.0

2 release files

0.45.0

2 release files

0.44.0

2 release files

0.43.0

2 release files

0.42.0

2 release files

0.41.0

2 release files

0.40.0

2 release files

0.39.0

2 release files

0.38.0

2 release files

0.37.0

2 release files

0.36.0

2 release files

0.35.0

2 release files

0.34.0

2 release files

0.33.0

2 release files

0.32.0

2 release files

0.31.0

2 release files

0.30.0

2 release files

0.29.0

2 release files

0.28.2

2 release files

0.28.1

2 release files

0.28.0

2 release files

0.27.0

2 release files

0.26.1

2 release files

0.26.0

2 release files

0.25.2

2 release files

0.25.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

1 release file

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page