Hyper
Write type-safe HTML in .hyper files. Import components directly from Python.
uv add hyperhtml
Requires Python 3.10 or newer.
Create a component
Create app/pages/Greeting.hyper:
<h1>Hello, World!</h1>
Import and call it:
from app.pages import Greeting
print(Greeting())
<h1>Hello, World!</h1>
The filename sets the component name.
Pass data
Add typed props above ---:
name: str
---
<h1>Hello, {name}!</h1>
print(Greeting(name="Ada"))
<h1>Hello, Ada!</h1>
Props are keyword-only. Values are escaped by default.
Calling a component binds its props. Rendering starts when it becomes a string or when you call .render():
greeting = Greeting(name="Ada")
html = greeting.render()
Use Python
Use Python expressions and control flow directly:
names: list[str]
---
for name in names:
<h1>Hello, {name}!</h1>
print(Greeting(names=["Ada", "Lin"]))
<h1>Hello, Ada!</h1><h1>Hello, Lin!</h1>
Indentation defines Python blocks. Add an aligned end only when it makes a boundary clearer.
Compose components
Create app/components/Card.hyper:
title: str
---
<article><h2>{title}</h2></article>
Use it from app/pages/Dashboard.hyper:
from app.components import Card
---
<{Card} title="Orders" />
from app.pages import Dashboard
print(Dashboard())
<article><h2>Orders</h2></article>
Pass content
Place {...} where caller content belongs:
title: str
---
<article>
<h2>{title}</h2>
<div>{...}</div>
</article>
Pass content between component tags:
from app.components import Card
---
<{Card} title="Orders">
<p>3 open orders</p>
</{Card}>
<article><h2>Orders</h2><div><p>3 open orders</p></div></article>
Pass named content
Use a named slot when content belongs in a specific place:
title: str
---
<article>
<h2>{title}</h2>
<div>{...}</div>
<footer>{...actions}</footer>
</article>
Mark the element that fills it:
from app.components import Card
---
<{Card} title="Orders">
<p>3 open orders</p>
<button {...actions}>View orders</button>
</{Card}>
<article><h2>Orders</h2><div><p>3 open orders</p></div><footer><button>View orders</button></footer></article>
Define several components
Use def ... -> Component to group related components in one file:
# app/components/forms.hyper
def Button(*, label: str) -> Component:
<button>{label}</button>
def Input(*, name: str) -> Component:
<input name={name} />
A declarations-only file imports like a Python module:
from app.components.forms import Button, Input
print(Button(label="Save"))
<button>Save</button>
.hyper files receive required runtime and typing imports automatically. In Python files, import the runtime from hyper:
from hyper import Component
Use FastAPI
Set the response type to HTML, then render a component:
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from app.pages import Dashboard
app = FastAPI(default_response_class=HTMLResponse)
@app.get("/dashboard")
def dashboard():
return Dashboard().render()
Stream a response
Pass stream=True to send each generated chunk:
from fastapi.responses import StreamingResponse
@app.get("/dashboard/stream")
def stream_dashboard():
return StreamingResponse(
Dashboard().render(stream=True),
media_type="text/html",
)
See Integrations for Django, Jinja, Flask, Litestar, and Sanic.
IDE support
- JetBrains: syntax highlighting, Python language injection, and compiler diagnostics
- TextMate and VS Code: syntax highlighting
Documentation
License
Metadata
Release files for hyperhtml 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hyperhtml-0.2.1.tar.gz | 154.6 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| hyperhtml-0.2.1-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| hyperhtml-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| hyperhtml-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ ARM64 | Details |
| hyperhtml-0.2.1-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| hyperhtml-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 2.9 MB
Release files / hyperhtml-0.2.1.tar.gz
| Download URL | hyperhtml-0.2.1.tar.gz |
|---|---|
| Size | 154.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c381fa5387829694150e84e5aa3ac6d5bb175c8c711a2e4ccd5cc60d717f913a
|
|
BLAKE2b-256 checksum How to use checksums |
e42de2178614b41ecbbd5f8e008a0ebb4b824775b02353fb4908b6e48eaa6410
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / hyperhtml-0.2.1-cp310-abi3-win_amd64.whl
| Download URL | hyperhtml-0.2.1-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 482.6 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
35f70f529ed75b4ff07e44a2b6a1812edde5985038d0224319e653ee02a11682
|
|
BLAKE2b-256 checksum How to use checksums |
ee897103227aa27256f7bf444da123ad09e183d676dc230edd79b03e9e21e1df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / hyperhtml-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | hyperhtml-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 603.7 kB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
4d94321074b718018cdbbd660a9e12c003816fb0febc07b3390845767ee76a05
|
|
BLAKE2b-256 checksum How to use checksums |
5e7123a3795276da322aa680a143eeb791e269e4d34562b2fdb94f15c515f7ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / hyperhtml-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | hyperhtml-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 552.7 kB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
be51518fb582a2268d0581c93fe62b201f17fad121e22bc3ecdde8af1704892e
|
|
BLAKE2b-256 checksum How to use checksums |
21226d3636c940b15aa4381c718cc0e6124a1ec5442ae7af273e872fc1d3f7a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / hyperhtml-0.2.1-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | hyperhtml-0.2.1-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 530.6 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
48c29a2da703364ee5072a6e62dc10ecbd04a5d1a0399431831eb5aebfc6fcd8
|
|
BLAKE2b-256 checksum How to use checksums |
9b43044ed849264ef32a2c3829f11050ca1ed7bf40ec09734429dc52102fa84c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / hyperhtml-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | hyperhtml-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 551.4 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
f06b0940f79b7a28124a782ad35b0ea352c8951261f8427d7ede780b911a9183
|
|
BLAKE2b-256 checksum How to use checksums |
f4e105f55f44eda007fc4983ef3f70db4144cb215589a13a2d305f19d66a4971
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|