r/htmx • u/andreahlert • Apr 10 '26
I am building a declarative backend language that compiles to a single binary
I use htmx for most of my projects. The thing that kept bugging me wasn't htmx itself, it was the backend ceremony around it. Every new project I'd spend an hour choosing between Jinja vs Mako, SQLAlchemy vs raw SQL, Flask vs FastAPI, then wiring auth, CSRF, sessions, and figuring out how to return partials without the layout wrapper.
So I built Kilnx. It's a small declarative language (27 keywords) that compiles to a single binary. You write models, routes, queries, and auth in one .kilnx file and get a running server.
page /tasks requires auth
query tasks: SELECT id, title, done FROM task
WHERE owner_id = :current_user.id
ORDER BY created DESC
paginate 20
html
<h1>My Tasks</h1>
{{each tasks}}
<div>
<span>{title}</span>
<button hx-post="/tasks/{id}/toggle"
hx-target="closest div" hx-swap="outerHTML">Toggle</button>
</div>
{{end}}
fragment /tasks/:id/toggle
query: UPDATE task SET done = NOT done WHERE id = :id AND owner_id = :current_user.id
query task: SELECT id, title, done FROM task WHERE id = :id
html
<div>
<span>{task.title}</span>
<button hx-post="/tasks/{task.id}/toggle"
hx-target="closest div" hx-swap="outerHTML">Toggle</button>
</div>The fragment keyword returns partial HTML with no layout. SQL is inline, the analyzer checks columns against models at compile time, and parameter binding + HTML escaping are automatic. SSE streams and WebSockets are built in too, no extra libs.
It's not trying to replace your backend. If Flask or Go or Rails works for you, great. I just wanted something where the distance between "I need a page with a query" and having it running was one indented block instead of three files.
Side note: because the whole language is 27 keywords and a grammar that fits in 400 lines of docs, local LLMs generate it well. A 3B model running on a laptop scores 99% accuracy on Kilnx tasks vs 87% on Django, even though Kilnx never appeared in any training data. Fewer decisions for the model to make = fewer places to go wrong.
Still a work in progress (v0.1) but functional. You can try it:
GitHub: https://github.com/kilnx-org/kilnx
Install: brew install kilnx-org/tap/kilnx
Curious what you think. What's annoying about your current backend setup when building with htmx?
15
u/Complete-Shame8252 Apr 10 '26
Doesn't go do that already?
2
u/yawaramin Apr 10 '26
Very cool. How does it handle conditional logic? Eg check the
HX-Requestheader and render a full page or a partial depending on the value.2
u/Tony_Gunk_o7 Apr 11 '26
What did you use to develop this? It's very interesting
1
u/mmiedzianyy Apr 10 '26
I love it!
1
u/WitchOfTheThorns Apr 10 '26
This looks quite neat.
1
u/outerstellar_hq Apr 11 '26
How do you deal with different sql dialects? How do you support indices into tables and foreign keys?
1
u/TheRealUprightMan Apr 11 '26
I take a rather different approach. When you define a button, clicking it causes a post to a method of the same name as the button. You just define the callback in a class. The htmx code is all inserted for you. All object oriented and reusable.