Leptos
Audited from github.com/leptos-rs/leptos
Leptos is a full-stack, isomorphic Rust web framework with fine-grained reactivity: components render to HTML on the server and hydrate as WebAssembly in the browser, with server functions as typed RPC.
- Language
- Rust
- License
- MIT
- Running for
- 3 years
- Team
- 6-20 people
Why this architecture
Leptos separates its reactive graph, renderer and server-function RPC into independent crates and keeps the core server-agnostic, so the same components run as SSR HTML or WebAssembly, and Axum or Actix Web plug in through thin integration crates.
Tech stack by layer
8 technologies · audited Oct 2, 2026- LeptosThe leptos crate (0.8 in its manifest): components, the view! macro, signals, resources and actions.
- WebAssemblyClient builds target the browser through wasm-bindgen, js-sys and web-sys, used across leptos_dom, meta and hydration_context.
- tachysRendering layer that turns views into DOM nodes in the browser or HTML strings on the server.
- reactive_graphFine-grained reactive system (signals, memos, effects) that the framework is built on; reactive_stores adds nested stores.
- server_fnServer functions: #[server] Rust functions compiled to HTTP endpoints on the server and to fetch calls on the client.
- AxumServer integration crate in integrations/axum for SSR, hydration and server-function routing.
- Actix-webAlternative server integration crate in integrations/actix with the same responsibilities as the Axum one.
- TokioOptional executor for any_spawner, which spawns tasks independently of the runtime (Tokio, wasm-bindgen futures, glib).
- GitHub ActionsCI computes changed crates and examples, then runs cargo-make tasks per crate; publish-book.yml deploys the book.
- cargo-makeMakefile.toml in every crate plus shared cargo-make/*.toml task files for lint, test, wasm-test and minimal-versions checks.
- Nixflake.nix and flake.lock provide a reproducible development shell.
Key architectural decisions
5 decisions- 01
Framework split into reactive, rendering and server layers
The root Cargo.toml lists reactive_graph and reactive_stores (state), tachys (rendering), hydration_context (server-to-client data), server_fn and leptos_server (RPC), router and meta as separate crates under the leptos facade, so the reactive core and renderer can evolve or be reused independently.
- 02
Server functions as the client-server boundary
server_fn and server_fn_macro turn an annotated async Rust function into an HTTP endpoint on the server and a typed client call in the browser. leptos_server exposes serialization codecs as features (miniserde, rkyv, serde-lite, serde-wasm-bindgen) so payload format is a build-time choice.
- 03
Server-agnostic core with Axum and Actix integrations
integrations/axum and integrations/actix are separate workspace members sharing integrations/utils, and any_spawner abstracts task spawning across Tokio, wasm-bindgen futures, async-executor and glib, so the core crates do not depend on a specific web server or runtime.
- 04
Examples and real projects kept out of the workspace
Cargo.toml excludes benchmarks, examples and projects from the workspace. examples/ holds dozens of focused apps (ssr_modes_axum, islands, todo_app_sqlite_axum, tailwind_axum, server_fns_axum), and projects/ holds larger integrations such as session_auth_axum, sso_auth_axum, ory-kratos and tauri-from-scratch.
- 05
Per-crate cargo-make tasks driven by change detection in CI
Every crate has a Makefile.toml, shared tasks live in cargo-make/ (lint, test, wasm-test, check-minimal-versions), and workflows such as get-leptos-changed.yml and get-examples-matrix.yml build a matrix of only the crates and examples a change touches before run-cargo-make-task.yml runs them.
How Leptos is built
How Leptos is structured
Leptos is a Cargo workspace with a facade crate (leptos/) on top of layered internals, all listed in the root Cargo.toml:
| Layer | Crates |
|---|---|
| Reactivity | reactive_graph, reactive_stores, reactive_stores_macro |
| Rendering | tachys, leptos_dom, leptos_macro (the view! macro) |
| Server and hydration | server_fn, server_fn_macro, leptos_server, hydration_context |
| App libraries | router, router_macro, meta (leptos_meta for title and meta tags), leptos_config |
| Integrations | integrations/axum, integrations/actix, integrations/utils |
| Utilities | any_spawner, any_error (throw_error), either_of, next_tuple, oco (oco_ref), or_poisoned, const_str_slice_concat |
benchmarks/, examples/ and projects/ are excluded from the workspace and build on their own. ARCHITECTURE.md documents the design, docs/book holds the user guide (also in Russian under docs/book_ru), and docs/COMMON_BUGS.md collects frequent mistakes. The repository also carries an AI_POLICY.md for contributions.
Frontend
Components are Rust functions marked #[component] that return impl IntoView. The README shows both the JSX-like view! macro and an equivalent builder syntax (div().child(...)). State uses signals from reactive_graph, and the README notes that signal handles are Copy, so they move into event closures without cloning.
There is no virtual DOM. The renderer in tachys attaches reactive updates to the exact nodes that read a signal. In the browser it works through wasm-bindgen, js-sys and web-sys. On the server the same views render to HTML strings. leptos_meta manages <title>, <meta> and <link> tags from inside components.
Backend & APIs
The server side has two parts:
- Server functions (
server_fn,server_fn_macro,leptos_server) compile an annotated async function into an HTTP endpoint on the server and a typed call on the client.leptos_server/Cargo.tomlexposes codec features (miniserde,rkyv,serde-lite,serde-wasm-bindgen) next to JSON. - Integrations connect routing, SSR and server functions to a web server.
integrations/axumandintegrations/actixshare helpers inintegrations/utils.
any_spawner keeps the core runtime-agnostic: tasks spawn on Tokio, wasm-bindgen futures, async-executor or glib depending on enabled features.
Data & persistence
Leptos has no data layer. The examples show the pattern: examples/todo_app_sqlite, todo_app_sqlite_axum and todo_app_sqlite_csr access SQLite from server functions. projects/session_auth_axum, projects/sso_auth_axum and projects/ory-kratos cover authentication.
Build, test & deploy
- Every crate has a
Makefile.toml, and shared cargo-make (opens in a new tab) tasks incargo-make/coverlint,test,wasm-testandcheck-minimal-versions. - CI is change-aware.
get-leptos-changed.yml,get-leptos-matrix.yml,get-example-changed.ymlandget-examples-matrix.ymlcompute which crates and examples a change touches, andrun-cargo-make-task.ymlruns only those.autofix.ymlapplies formatting fixes, andpublish-book.ymlpublishes the book. .config/nextest.tomlconfigurescargo-nextest, andflake.nixprovides a Nix development shell.- The workspace targets Rust edition 2021 with a minimum Rust version of 1.88.
What to copy (and what not to)
Copy:
- Layered crates behind one facade. Users depend on
leptos, while the reactive core, renderer and RPC can be tested and versioned on their own. - A runtime abstraction (
any_spawner) so library code never hard-codes Tokio. That is what lets the same crates run in the browser and on the server. - Change-aware CI matrices for a large workspace with many examples.
- Examples outside the workspace, so their dependencies (SQLite, auth providers, Tailwind) never leak into the framework.
Don't copy blindly:
- Many tiny utility crates (
next_tuple,or_poisoned,const_str_slice_concat) suit a framework that publishes to crates.io. An application should keep such helpers as modules. - Supporting several serialization codecs and two server integrations multiplies the test matrix.
To build an app on Leptos, see the Leptos full-stack rules. Dioxus takes a different approach: a cross-platform renderer rather than an SSR-first one.
Sources & repo audit
- Workspace Cargo.toml (members, excludes, workspace dependencies)
- leptos/Cargo.toml
- leptos_server/Cargo.toml (server function codecs)
- any_spawner/Cargo.toml (executor-independent spawning)
- README (component example)
Independent analysis of repository at github.com/leptos-rs/leptos. Spotted an inaccuracy? Use the claim form to request a correction.
Maintainer? Add the architecture badge to your README
[](https://stackitfast.com/project/leptos) Scaffold it with your agent
Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with Leptos's architecture.
- 1Copy the promptThe full markdown spec, with every layer and decision.
- 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
- 3Paste and scaffoldUse it as the first instruction; review before you ship.
# MISSION: Scaffold "Leptos" Production Architecture
You are an expert Senior Staff Software Architect and Full-Stack Engineer. Your mission is to scaffold and implement a production-grade, highly reliable, and modular codebase following the proven architecture of **Leptos**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: Leptos
- **What It Does**: Leptos is a full-stack, isomorphic Rust web framework with fine-grained reactivity: components render to HTML on the server and hydrate as WebAssembly in the browser, with server functions as typed RPC.
- **Domain & Category**: Full-Stack Rust Web Framework
- **Production Scale**: 6-20 people
- **Development Mode**: CLASSIC
- **Architectural Rationale**: Leptos separates its reactive graph, renderer and server-function RPC into independent crates and keeps the core server-agnostic, so the same components run as SSR HTML or WebAssembly, and Axum or Actix Web plug in through thin integration crates.
- **Live Website Reference**: https://leptos.dev
- **Source Repository**: https://github.com/leptos-rs/leptos
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: Rust, Leptos, WebAssembly, Axum, Actix-web, Tokio, Nix, GitHub Actions
- **Primary Language(s)**: Rust, JavaScript, TypeScript
- **License of the reference repo**: MIT
- **Frontend**: Leptos — The leptos crate (0.8 in its manifest): components, the view! macro, signals, resources and actions.; WebAssembly — Client builds target the browser through wasm-bindgen, js-sys and web-sys, used across leptos_dom, meta and hydration_context.; tachys — Rendering layer that turns views into DOM nodes in the browser or HTML strings on the server.; reactive_graph — Fine-grained reactive system (signals, memos, effects) that the framework is built on; reactive_stores adds nested stores.
- **Backend & APIs**: server_fn — Server functions: #[server] Rust functions compiled to HTTP endpoints on the server and to fetch calls on the client.; Axum — Server integration crate in integrations/axum for SSR, hydration and server-function routing.; Actix-web — Alternative server integration crate in integrations/actix with the same responsibilities as the Axum one.; Tokio — Optional executor for any_spawner, which spawns tasks independently of the runtime (Tokio, wasm-bindgen futures, glib).
- **Infrastructure & deploy**: GitHub Actions — CI computes changed crates and examples, then runs cargo-make tasks per crate; publish-book.yml deploys the book.; cargo-make — Makefile.toml in every crate plus shared cargo-make/*.toml task files for lint, test, wasm-test and minimal-versions checks.; Nix — flake.nix and flake.lock provide a reproducible development shell.
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/leptos-rs/leptos @ 08fe6e2)
1. **Framework split into reactive, rendering and server layers**: The root Cargo.toml lists reactive_graph and reactive_stores (state), tachys (rendering), hydration_context (server-to-client data), server_fn and leptos_server (RPC), router and meta as separate crates under the leptos facade, so the reactive core and renderer can evolve or be reused independently.
2. **Server functions as the client-server boundary**: server_fn and server_fn_macro turn an annotated async Rust function into an HTTP endpoint on the server and a typed client call in the browser. leptos_server exposes serialization codecs as features (miniserde, rkyv, serde-lite, serde-wasm-bindgen) so payload format is a build-time choice.
3. **Server-agnostic core with Axum and Actix integrations**: integrations/axum and integrations/actix are separate workspace members sharing integrations/utils, and any_spawner abstracts task spawning across Tokio, wasm-bindgen futures, async-executor and glib, so the core crates do not depend on a specific web server or runtime.
4. **Examples and real projects kept out of the workspace**: Cargo.toml excludes benchmarks, examples and projects from the workspace. examples/ holds dozens of focused apps (ssr_modes_axum, islands, todo_app_sqlite_axum, tailwind_axum, server_fns_axum), and projects/ holds larger integrations such as session_auth_axum, sso_auth_axum, ory-kratos and tauri-from-scratch.
5. **Per-crate cargo-make tasks driven by change detection in CI**: Every crate has a Makefile.toml, shared tasks live in cargo-make/ (lint, test, wasm-test, check-minimal-versions), and workflows such as get-leptos-changed.yml and get-examples-matrix.yml build a matrix of only the crates and examples a change touches before run-cargo-make-task.yml runs them.
---
## 4. NON-NEGOTIABLE ARCHITECTURAL GUARDRAILS
1. **Monorepo & Modular Separation**:
- Structure as a Turborepo monorepo with strict package boundaries:
- `apps/web`: Application UI, routing, layouts, and server endpoints.
- `packages/ui`: Shared design tokens, CSS variables, and Radix UI primitive components.
- `packages/db`: Database schemas, client singleton, declarative migrations, and seed scripts.
- `packages/config`: Shared TypeScript, ESLint, and build configurations.
2. **Strict Type Safety & Zero `any` Policy**:
- Enable `strict: true`, `noImplicitAny: true`, and `strictNullChecks: true`.
- Validate ALL external inputs, API request bodies, and query parameters with **Zod** schemas before execution.
3. **Frontend & Rendering Guidelines**:
- Isolate interactive UI state to leaf components. Keep core pages lightweight and performant.
4. **Design System & Aesthetics**:
- Keep every color, radius, shadow and font in a single token file (CSS variables) and consume tokens everywhere; never hardcode hex values in components.
- Prefer crisp 1px borders and one subtle shadow scale over blurry default shadows. Pair one sans-serif for body/headings with one monospace for tags, badges, metrics, and code.
5. **Data Layer & Reliability**:
- Write declarative schema definitions with foreign keys, composite indexes on queried filters, and automated timestamp triggers.
- Use connection pooling and prepared statements for serverless database execution.
---
## 5. STEP-BY-STEP SCAFFOLDING ROADMAP
- **Phase 1: Workspace & Root Config**: Initialize package manager, monorepo configuration (`turbo.json`, `tsconfig.base.json`, `package.json`).
- **Phase 2: Database Schema & Client**: Set up the data layer: client, connection pool, models, and migration scripts.
- **Phase 3: Design Tokens & UI Primitives**: Build accessible `Button`, `Input`, `Card`, `Badge`, and layout wrappers inside `packages/ui`.
- **Phase 4: Core Application Routes & Handlers**: Implement primary authentication, user session handling, and application routes.
- **Phase 5: Quality Assurance & Build Verification**: Run `tsc --noEmit`, ESLint, Prettier, and smoke test suites to ensure zero compilation or runtime errors.
---
## 6. EXECUTION INSTRUCTIONS
1. Review all specifications, architectural guardrails, and stack choices above.
2. Present the full monorepo directory tree structure.
3. Systematically generate the complete, production-ready codebase according to the 5-phase roadmap above — starting with the root workspace setup, followed by the database schema, UI design system package, and full-stack application routes until the repository is fully scaffolded and ready to run.Frequently asked about Leptos
What is Leptos built with?
Leptos is written in Rust and compiles to WebAssembly for the browser through wasm-bindgen and web-sys. Internally it is split into reactive_graph (signals), tachys (rendering), server_fn (server functions), a router and a meta crate, with server integrations for Axum and Actix Web.
Does Leptos use a virtual DOM?
No. Leptos uses fine-grained reactivity from its reactive_graph crate: signals update the exact DOM nodes that read them, and the tachys renderer produces DOM in the browser or HTML strings on the server.
Can Leptos do server-side rendering?
Yes. Leptos supports SSR with hydration, and the repository includes ssr_modes and ssr_modes_axum examples plus islands examples for partial hydration. The server side runs on Axum or Actix Web through the integrations crates.
Does Leptos work with Axum or Actix Web?
Both. The repository contains integrations/axum and integrations/actix as separate crates, and examples such as todo_app_sqlite_axum, tailwind_axum and tailwind_actix show each setup.
Is Leptos production-ready?
The leptos crate is versioned 0.8 in the audited repository and requires Rust 1.88 or newer. The repository includes production-style projects such as session_auth_axum, sso_auth_axum and an Ory Kratos integration.
One email a month: new deep dives and stack trends
New source-audited architectures, head-to-head comparisons and the monthly stack report. No spam, unsubscribe anytime.
Similar architectures
- Actix WebClassicRust Web Framework · 1M+ MAUShares Rust · Actix-web · Tokio
- AxumClassicRust Web Framework · 1M+ MAUShares Rust · Axum · Tokio
- DioxusClassicCross-Platform Rust App Framework · 6-20 peopleShares Rust · WebAssembly · Axum
- MeilisearchClassicSearch Engine · 20+ peopleShares Rust · Actix-web · Tokio
- crates.ioClassicPackage Registry · 1M+ MAUShares Rust · Axum · Tokio
- DenoClassicSecure JavaScript & TypeScript Runtime · 20+ peopleShares Rust · Tokio