Rust web development just got more interesting.
If you prefer a video version:
A few days ago, I spoke with Carl Lerche and Julien Scholz about Topcoat, a new batteries-included framework for building full-stack reactive web applications with Rust.
Now I have finally tried it myself.
Topcoat comes from the ecosystem behind Tokio and Axum, but it aims to provide a very different experience: routing, server-side rendering, reactive components, UI tooling, asset bundling, and hot reload in one framework.
A simple Topcoat application
This is what a basic application looks like:
use topcoat::{
Result,
router::{Router, RouterBuilderDiscoverExt, page},
view::{component, view},
};
#[tokio::main]
async fn main() {
topcoat::start(Router::builder().discover().build())
.await
.unwrap();
}
#[page("/")]
async fn home() -> Result {
view! {
<!DOCTYPE html>
<html>
<body>
hello(name: "World")
</body>
</html>
}
}
#[component]
async fn hello(name: &str) -> Result {
view! { <h1>"Hello, " (name) "!"</h1> }
}
The syntax feels surprisingly familiar if you have used server-rendered frameworks before.
Pages and components are written in Rust, while the view! macro keeps the HTML structure easy to understand.
What surprised me
My first experience was better than expected.
The setup was simple, the basic example was actually basic, and the development server provided working hot reload.
That last part may sound normal to JavaScript developers, but it makes a huge difference for the Rust developer experience.
Topcoat includes or plans to support:
- Server-side rendering
- Reactive components
- Module-based routing
- Tailwind integration
- Reusable UI components
- Asset bundling
- Fonts and icons
- Cookies and sessions
- Database integrations
The experience feels closer to frameworks such as Laravel, Django, Rails, or Next.js, while allowing developers to build the application in Rust.
Is Topcoat ready for production?
Topcoat is still at an early stage.
Breaking changes should be expected, and I would not migrate an important production application to it yet.
However, the initial developer experience is already promising.
The combination of Rust’s performance and type safety with the productivity of a batteries-included framework is something I have wanted to see for a long time.
I’m starting a Topcoat series
This video officially starts a new YouTube series in which I will test Topcoat, build applications with it, and follow its development.
I also published a conversation with Carl Lerche and Julien Scholz about the ideas behind the framework:
I am genuinely curious to see where this project goes.
Would you use a full-stack Rust framework like Topcoat? What should I build with it next?
Top comments (0)