<< All versions

Skill v1.0.0

currentAutomated scan100/100
adelabdelgawad/rust-fullstack-agents/cargo-leptos-config
──Details
PublishedNovember 18, 2026 at 08:35 PM
Content Hashsha256:037e582924d44f2c...
Git SHA5a9eb23b4768
──Files
Files (1 file, 6.3 KB)
SKILL.md6.3 KBactive
SKILL.md · 190 lines · 6.3 KB

name: cargo-leptos-config description: Configure cargo-leptos via [package.metadata.leptos] or [[workspace.metadata.leptos]]. Auto-triggers when adding/modifying Cargo.toml metadata for a Leptos project, changing site-addr/style/assets, or debugging cargo leptos build failures. metadata: version: "1.0.0"


Cargo-Leptos Config

When to Use

Invoke before:

  • Adding [package.metadata.leptos] to a new project.
  • Adding [[workspace.metadata.leptos]] to a workspace with multiple Leptos apps.
  • Changing site-addr, style-file, tailwind-input-file, assets-dir, or feature sets.
  • Debugging cargo leptos build / cargo leptos watch failures related to config.
  • Switching from Trunk (CSR-only) to cargo-leptos (SSR+hydrate).

Note: CSR-only apps are NOT supported under cargo-leptos. Use Trunk for CSR.

Core Patterns

Pattern 1 — Single-Package Metadata Block

For single-crate Leptos projects (no workspace). Placed in the root Cargo.toml.

toml
[package]
name = "my_app"
version = "0.1.0"
edition = "2021"
[package.metadata.leptos]
# Required
output-name = "my_app"
# Build
bin-features = ["ssr"]
lib-features = ["hydrate"]
bin-default-features = false # IMPORTANT: opposite of Cargo default
lib-default-features = false # IMPORTANT: opposite of Cargo default
# Dev server
site-addr = "127.0.0.1:3000"
# Output paths
site-root = "target/site"
site-pkg-dir = "pkg"
# Assets
assets-dir = "public"
style-file = "style/main.scss"
# Testing
end2end-cmd = "npx playwright test"
end2end-dir = "end2end"

Anti-pattern — omitting bin/lib-default-features:

toml
# BAD: without bin-default-features = false, cargo-leptos enables ALL default
# features for the binary — e.g., client-side wasm deps leak into SSR binary.
[package.metadata.leptos]
output-name = "my_app"
# bin-default-features missing → defaults to false, but leaving it out
# makes it unclear to reviewers. Always state explicitly.

Pattern 2 — Workspace Array-of-Tables

For workspaces with multiple Leptos apps. Uses [[workspace.metadata.leptos]] (array of tables). Each entry requires name, bin-package, lib-package.

toml
# Cargo.toml (workspace root)
[[workspace.metadata.leptos]]
name = "admin"
bin-package = "admin-server"
lib-package = "admin-ui"
output-name = "admin"
site-addr = "127.0.0.1:3001"
bin-features = ["ssr"]
lib-features = ["hydrate"]
bin-default-features = false
lib-default-features = false
style-file = "admin-ui/style/main.scss"
assets-dir = "admin-ui/public"
[[workspace.metadata.leptos]]
name = "storefront"
bin-package = "storefront-server"
lib-package = "storefront-ui"
output-name = "storefront"
site-addr = "127.0.0.1:3002"
bin-features = ["ssr"]
lib-features = ["hydrate"]
bin-default-features = false
lib-default-features = false

Anti-pattern — using [workspace.metadata.leptos] (single table) in a workspace:

toml
# BAD: single-table form is for [package.metadata.leptos] only.
# Workspaces MUST use [[workspace.metadata.leptos]] (double-bracket array).
[workspace.metadata.leptos] # ← wrong form for workspaces
name = "my_app"

Pattern 3 — Tailwind Integration

When using Tailwind CSS, provide both tailwind-input-file and tailwind-config-file. cargo-leptos runs the Tailwind CLI automatically on cargo leptos watch.

toml
[package.metadata.leptos]
output-name = "my_app"
tailwind-input-file = "style/input.css"
tailwind-config-file = "tailwind.config.js"
# Do NOT also set style-file when using tailwind — pick one
bin-features = ["ssr"]
lib-features = ["hydrate"]
bin-default-features = false
lib-default-features = false

Anti-pattern — setting both style-file and tailwind-input-file:

toml
# BAD: ambiguous — cargo-leptos behaviour is undefined when both are present.
style-file = "style/main.scss"
tailwind-input-file = "style/input.css" # ← conflict

Pattern 4 — Custom Server-Fn Prefix

The server-fn-prefix key controls the HTTP path prefix used for all #[server] fn routes. Default is /api. Must match the Axum mount point.

toml
[package.metadata.leptos]
output-name = "my_app"
server-fn-prefix = "/api/v1" # all server fns mount under /api/v1
bin-features = ["ssr"]
lib-features = ["hydrate"]
bin-default-features = false
lib-default-features = false
rust
// Axum main.rs — prefix must match cargo-leptos config
let routes = generate_route_list(App);
let router = Router::new()
.leptos_routes_with_context(&leptos_options, routes, provide_context_fn, shell)
.with_state(state);

Anti-pattern — mismatch between config prefix and axum mount:

rust
// BAD: config says /api/v1 but axum mounts at /api → 404 on all server fns
Router::new()
.nest("/api", server_fn_routes) // ← doesn't match /api/v1

Anti-Patterns to Block

  • Using cargo leptos for a CSR-only app → switch to Trunk; cargo-leptos does not support CSR.
  • Missing name / bin-package / lib-package in workspace array entry → all three are required.
  • bin-default-features or lib-default-features not set to false → always set explicitly to avoid leaking features across targets.
  • [[workspace.metadata.leptos]] entries with identical site-addr → each app must bind a distinct port.
  • style-file and tailwind-input-file both set → pick exactly one CSS pipeline.
  • server-fn-prefix in config not matching the Axum router mount → mismatched prefix causes silent 404s on all server fns.
  • js-dir changed without moving actual JS files → cargo-leptos will silently fail to bundle JS.

Verification Hooks

bash
# Confirm metadata block exists
grep -n 'metadata.leptos' Cargo.toml
# Confirm bin/lib-default-features are both false
grep -n 'default-features' Cargo.toml
# Confirm server-fn-prefix matches the Axum mount
grep -rn 'server-fn-prefix' Cargo.toml
grep -rn 'nest\|leptos_routes' src/
# Dry-run build to catch config errors before watching
cargo leptos build 2>&1 | head -40
# List all registered leptos projects in workspace
cargo leptos list 2>/dev/null || true

References

  • https://github.com/leptos-rs/cargo-leptos (README — full key reference)
  • https://book.leptos.dev/deployment/cargo_leptos.html
  • https://docs.rs/cargo-leptos
All versions