What is Dioxus Fullstack?
Dioxus Fullstack bridges the gap between client and server, providing:- Server Functions: Call server-side code from the client with automatic serialization
- Server-Side Rendering (SSR): Pre-render your UI on the server for faster initial loads and better SEO
- Hydration: Seamlessly take over server-rendered HTML on the client
- Unified Codebase: Share types, validation logic, and business logic between client and server
- Type Safety: Full type checking across the client-server boundary
Architecture
Dioxus Fullstack applications consist of two main parts:Server Side
- Axum Integration: Built on the battle-tested Axum web framework
- Automatic Routing: Server functions are automatically registered as HTTP endpoints
- SSR Rendering: Components render to HTML on the server
- Hydration Data Injection: Server state is serialized and embedded in the HTML
Client Side
- WASM Application: Compiled to WebAssembly for browser execution
- Automatic Hydration: Picks up where the server left off
- RPC-style Calls: Server functions appear as async Rust functions
- Type-Safe Communication: Same types on client and server
When to Use Fullstack
Dioxus Fullstack is ideal for: ✅ Web Applications- Dashboard and admin panels
- Content management systems
- E-commerce sites
- Social platforms
- Marketing pages
- Blogs and documentation
- Landing pages
- Chat applications
- Collaborative tools
- Live dashboards
- Server-rendered base experience
- Enhanced interactivity on capable devices
When NOT to Use Fullstack
Consider alternatives if:- Desktop/Mobile Apps: Use
dioxus::launchwithout server features for pure desktop/mobile apps - Static Sites: Use SSG (Static Site Generation) if content rarely changes
- Microservices: If you need separate deployment of frontend and backend
- Non-Rust Backend: If your backend must be in another language, use the
webrenderer with a separate API
Key Features
Unified Development Experience
Automatic Code Splitting
Code marked with#[server] is automatically excluded from the client bundle:
Cross-Platform Server Functions
Server functions work from any Dioxus platform:Getting Started
Create a new fullstack project:- Axum server on
http://localhost:8080 - Hot-reload dev server
- Automatic rebuilds on file changes
Project Structure
Cargo.toml:
Development Workflow
- Write Components: Create your UI in
rsx! - Add Server Functions: Mark async functions with
#[server]or#[get]/#[post] - Call from Client: Use
use_actionto call server functions - Test Locally:
dx serveruns everything locally - Deploy: Build and deploy to any Rust-compatible host
Next Steps
Server Functions
Learn how to define and call server functions
Server-Side Rendering
Understand SSR and how to configure it
Hydration
Deep dive into the hydration process
Middleware
Add authentication, logging, and custom middleware
Examples
Check out the fullstack examples in the Dioxus repository:examples/07-fullstack/fullstack_hello_world.rs- Basic server function usageexamples/07-fullstack/server_functions.rs- Advanced patternsexamples/07-fullstack/middleware.rs- Adding middlewareexamples/07-fullstack/server_state.rs- Managing server stateexamples/07-fullstack/streaming.rs- Streaming responses