• 2 min read
Topcoat brings full-stack Rust to one framework
Topcoat is an experimental, modular Rust framework for full-stack apps, combining server rendering, client reactivity, routing, assets, and Tailwind support.

Image: Hacker News
Topcoat is an early-stage, experimental Rust framework for building full-stack applications from a single codebase. The modular, batteries-included project prioritizes simplicity and productivity, while warning developers to expect breaking changes.
A minimal application starts a discovered router and defines a page with #[page(“/”)]. Components are asynchronous Rust functions annotated with #[component], and the view! macro produces HTML-like templates:
''rust #[tokio::main] async fn main() { topcoat::start(Router::builder().discover().build()).await.unwrap(); } ''
Server rendering with client reactivity
Topcoat renders markup on the server, allowing components to query a database directly without the usual separate API layer. Client-side interactions use $(…) expressions: these are type-checked Rust evaluated during the initial server render and translated to JavaScript for immediate browser-side updates.
That approach requires no WebAssembly bundle and no client build step. When an interaction needs fresh server data, developers can mark a component as a #[shard]. Topcoat then re-renders the shard when one of its $(…) arguments changes and swaps the resulting HTML into place—for example, updating search results as a user types.

Recommended reading
Open Book Touch Makes Open-Source Reading Pocket-Sized
Routing, assets, and integrations
The view! macro combines familiar HTML with ordinary Rust control flow, including loops and conditional attributes. The topcoat fmt CLI command formats view! snippets and other macros across a codebase.
Routing can be declared manually or inferred from the module tree without a build step. Files such as about.rs, pricing.rs, and health.rs can map to /about, /pricing, and GET /api/health; dynamic modules can produce routes such as /posts/{post_id}. Underscored modules provide layouts without adding a URL segment.
The asset bundler scans compiled binaries for asset! calls, copies or downloads referenced files into a local asset directory, and serves them with aggressive browser caching. Topcoat also includes utilities for web fonts and icons, plus integrations with Fontsource and Iconify.
Enabling the tailwind feature adds Tailwind CSS without Node, through the asset pipeline. The framework also provides helpers for htmx, request and application context, per-request memoization, cookies, sessions, authentication flows, and API routes. Developers can start with the getting-started guide, install the CLI, and run the development server.
Computing Editor
Tomas lives in the terminal. He covers chips, laptops, and operating systems with a focus on performance and efficiency. He reads kernel changelogs the way other people read fiction, and he's always on the hunt for the perfect mechanical keyboard switch. If it processes data, Tomas has an opinion on it.
via Hacker News


