Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Topcoat
Early-stage and experimental. Expect breaking changes.
A modular, batteries-included Rust web framework for server-rendered apps.
See the Getting started guide to set up a new project.
use ;
async
async
async
What makes Topcoat different
Powerful, unsurprising HTML templates
The view! macro stays true to HTML and Rust. Use familiar Rust control flow as part of your templates:
view!
Use the topcoat fmt CLI command to automatically format view! snippets across your codebase.
Module-based routing
Topcoat can optionally infer your route tree from your app's module structure (without a build step):
src/
|-- app.rs -> / (and the root layout)
`-- app/
|-- about.rs -> /about
|-- _marketing.rs (layout, no URL segment)
|-- _marketing/
| `-- pricing.rs -> /pricing
|-- posts.rs -> /posts
|-- posts/
| `-- id.rs -> /posts/{post_id}
`-- api/
`-- health.rs -> GET /api/health
Asset bundling
The bundler scans your compiled binary for asset! calls, copies (or even downloads) every file into a local asset directory, and allows Topcoat to serve them efficiently with aggressive browser caching.
const FERRIS: Asset = asset!;
view!
Built-in Tailwind support
Enabled the tailwind feature to integrate Tailwind into your project effortlessly:
view!
Learn Topcoat
Start here
- Getting started: create a new project, install the CLI, run the dev server.
- Source code formatting:
topcoat fmtfor macro bodies.
Rendering
- The
view!macro: templating syntax, control flow, conditional attributes. - The
#[component]macro: async functions as components, with child content. - The
attributes!macro: reusable runtime attribute fragments. - The
class!macro: space-separated class lists from static and conditional entries.
Routing
- Router: pages, layouts, and API routes; manual and auto-discovered.
- Module-based routing: derive the route table from your module tree.
Working with requests
- Request context (
Cx): the value pages, layouts, and components read from. - App context: share long-lived values across requests, keyed by type.
- Cookies: read and write the request cookie jar, with signed, encrypted, and prefixed cookies.
- Memoization:
#[memoize]for per-request caching and fan-out dedup. - Functions, not middlewares: the recommended way to model auth and other request-scoped concerns.
Asset system
- Assets: declare assets in Rust, serve them with content-hashed URLs.
- Fonts: bundle and serve web fonts.
- Icons: download Iconify icon sets or declare your own.
Third-party integrations