HTML over the wire with Maud, Tailwind v4, Basecoat, HTMX, and Alpine
Slabs renders HTML directly in Rust without Node.js, npm, webpack, Vite, or a separate client-side single-page application layer. Every browser library in the stack is MIT-licensed and embedded directly into the slabs-http binary.
Why zero Node and zero JSON state duplication
Splitting a web app into a Rust JSON backend plus a React or TypeScript frontend doubles every change. You maintain duplicate types, duplicate validation, client-side routing, cache invalidation, and a Node build pipeline.
In Slabs, the server owns the database, validation, authorization, and HTML rendering in one file. When an agent writes a slab, rustc type-checks the SQL parameters, Rust variables, and Maud HTML markup in the same compilation unit.
How the five frontend pieces fit together
- Maud (
maud!macro inslabs-html) compiles HTML templates directly into Rust code that appends to aString. Every interpolated value is HTML-escaped at compile time.PreEscapedis omitted fromslabs::prelude::*on purpose so raw HTML requires an explicitslabs::html::PreEscapedimport, and untrusted Markdown runs throughhtml::render_markdown(&text). - Tailwind CSS v4 runs as a single standalone native binary via
misewith zeronode_modules.assets/input.csscontains@import "tailwindcss";and@source "../slabs";, soslabs cssscans every slab file and outputs a minifiedassets/styles/app.cssserved at a content-hashed/assets/{hash}/styles/app.cssURL withCache-Control: public, max-age=31536000, immutable. - Basecoat UI (
/_slabs/vendor/basecoat.min.cssandbasecoat.min.js) ships shadcn-style CSS tokens (--background,--foreground,--card,--border,--muted,--primary) and semantic HTML classes (.btn,.card,.input,.badge) with no React or Radix dependency. - HTMX 2, SSE, and Idiomorph (
/_slabs/vendor/htmx.min.js,htmx-ext-sse.js,idiomorph-ext.min.js) drive partial page updates (hx-get,hx-post,hx-target,hx-push-url), out-of-band updates (htmx::oob,htmx::oob_replace,htmx::oob_delete), live server pushes (sse-connect,sse-swap), and DOM diffing (hx-swap="morph:innerHTML").html::documentenableshx-ext="morph"on<body>and@view-transition { navigation: auto; }in<head>. - Alpine.js 3 (
/_slabs/vendor/alpine.min.js) and native HTML elements handle transient browser-only state such as keyboard shortcuts (@keydown.window), dropdown toggles, and copy buttons. Modals and popovers use native<dialog>and the HTMLpopoverattribute instead of custom focus-trap libraries.
Safe JSON embedding and guarded redirects
Two slabs-html helpers prevent common frontend injection and redirect bugs:
json_script("boot-data", &payload)?serializes structured data into<script type="application/json" id="boot-data">and escapes<,>,&, U+2028, and U+2029 so user strings cannot break out of the script tag.htmx::redirect(path)andhtmx::flash_redirect(...)verify thatpathis a safe relative path and fall back to"/"on open-redirect inputs such as//evil.com. Callredirect_external(url)when an endpoint intentionally redirects to another origin.
Progressive rendering with htmx::is_htmx
A single slab can serve both full browser navigations and partial HTMX swaps by checking htmx::is_htmx(&headers):
- On a normal browser request, return the full
html::document(...)shell with sidebar, navigation bar, and article content. - On an HTMX click (
HX-Request: truewithhx-target="#doc-article"andhx-push-url="true"), return only the<article>fragment plus anhtmx::oob_replacefor the sidebar active link or document<title>.
Direct URLs, browser back/forward buttons, and search engine crawlers work cleanly because every link is a standard <a href="..."> upgraded with hx-get.
Serving AI agents alongside browsers
Because routes return typed responses from self-contained slabs, exposing plain Markdown (/raw/{section}/{slug}) or /llms.txt alongside HTML pages takes a small sibling slab reading the same SQLite tables with zero client-side JavaScript overhead.