Skip to main content

fjkit

fjkit is the UI layer FastAPI does not ship: pages, tables, forms, navigation, dark mode and htmx swaps, composed as Jinja macros in the same codebase as your handlers.

Your app has no front-end build step. The stylesheet is compiled when fjkit is released, not when your app runs, so your repo has no package.json, no node_modules and no Tailwind binary. Every other rule in fjkit protects that one.

Install

Requires Python 3.13+. The runtime dependencies are fastapi, jinja2 and pydantic, and fastapi already requires pydantic.

uv add fjkit

A working page

app/main.py:

from pathlib import Path

from fastapi import FastAPI
from fjkit import FjkitConfig, mount_fjkit, render
from pydantic import BaseModel

app = FastAPI()
mount_fjkit(app, FjkitConfig(template_dir=Path(__file__).parent / "templates"))


class Overview(BaseModel):
    done: int


@app.get("/")
@render("overview.html")
def overview() -> Overview:
    return Overview(done=18)

app/templates/overview.html:

{% extends "ui/shell.html" %}
{% from "ui/layout.html" import page_header, grid %}
{% from "ui/data.html" import stat %}

{% block content %}
  {{ page_header("Overview", "How the board is doing") }}
  {% call grid(cols=4) %}
    {{ stat("Done", done, tone="success", icon_name="check") }}
  {% endcall %}
{% endblock %}

Run uv run fastapi dev app/main.py and open http://127.0.0.1:8000. @render goes below @app.get and passes the returned model's fields to the template.

Rebranding

One knob, plain CSS, no build:

/* your own stylesheet, loaded after fjkit's */
:root { --primary: oklch(0.55 0.2 145); --primary-foreground: oklch(0.99 0 0); }

One handler, two wire formats

A handler returns a model, not markup. @render picks the format from whether the caller has markup waiting, so a fragment route is the app's JSON API without a second route:

$ curl -s localhost:8000/tasks/board
{"tasks": [...], "stats": {"total": 8, "done_pct": 25}}

$ curl -s -H 'HX-Request: true' localhost:8000/tasks/board
<div id="board">...</div>

The return annotation describes both, so FastAPI has already put the JSON in /docs. mode="html" or mode="json" on the decorator forces one.

Checking your templates

fjkit's class vocabulary is closed — apps compose macros rather than writing utility classes. That is what makes the no-build promise hold, and it is enforceable:

uv run fjkit check app/templates

Documentation

Docs

Status: 0.4.4. Macro signatures can change before 1.0.

License

MIT. See LICENSE.

Metadata

Release files for fjkit 0.4.4

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

Source distribution (sdist)

Source distribution for fjkit 0.4.4
File Size Uploaded Provenance Actions
fjkit-0.4.4.tar.gz 946.9 kB Without provenance Details for fjkit-0.4.4.tar.gz

Built distribution (wheel)

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

Total release size: 1.6 MB

Release files / fjkit-0.4.4.tar.gz

Download URL fjkit-0.4.4.tar.gz
Size 946.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b8762952c3271fa6ef8aa4c69cb55f6cb7ffc57a58d31a5357a179c0d226ca40
BLAKE2b-256 checksum
How to use checksums
d533b10efc100f59acf8ca42b20f4fb6d73e4b21dc543d9778c8e9903583f6c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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 / fjkit-0.4.4-py3-none-any.whl

Download URL fjkit-0.4.4-py3-none-any.whl
Size 636.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c59a42aecc0c0312d0e3ef8b948fd7766e99b5639e60df62b198628f08f6b615
BLAKE2b-256 checksum
How to use checksums
a05ff2b211b24d47f7236e6cbe406e9907dc24f88a958bdce409d38ab9b7fcfb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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}

Security for fjkit 0.4.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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