Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Workspace/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Development

Depending on your selected options, your new workspace project contains a workspace member for each platform.

If you chose to develop with the router feature, each platform crate will have a `views` folder for your platform-specific views.
You are provided with a `ui` crate for shared UI and if you chose to use fullstack, you will have a `server` crate for your shared server functions.

You are provided with a `ui` crate for shared UI and if you chose to use fullstack, you will have a `server` crate for your shared server functions.

Code gated with the `server` feature in the `server` crate will only be available on the actual server side and can be used e.g. for `axum` integration such as authentication middleware. This distinction is required because the declaration of [server functions](https://crates.io/crates/server_fn) also declares their respective clients.

### Serving Your App

Expand Down
3 changes: 3 additions & 0 deletions Workspace/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ edition = "2021"

[dependencies]
dioxus = { workspace = true, features = ["fullstack"] }

[features]
server = []
5 changes: 5 additions & 0 deletions Workspace/server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
//! This crate contains all shared fullstack server functions.
use dioxus::prelude::*;

#[cfg(feature = "server")]
pub mod server {
use super::*;
}

/// Echo the user input on the server.
#[server(Echo)]
pub async fn echo(input: String) -> Result<String, ServerFnError> {
Expand Down
2 changes: 1 addition & 1 deletion Workspace/web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ ui = { workspace = true }
default = [{% if is_fullstack == false -%}"web"{%- endif %}]
web = ["dioxus/web"]
{% if is_fullstack -%}
server = ["dioxus/server"]
server = ["dioxus/server", "server/server"]
{%- endif %}