Skip to content

feat(cli): support custom renderers via [renderer] config#5416

Open
rlch wants to merge 1 commit intoDioxusLabs:mainfrom
rlch:main
Open

feat(cli): support custom renderers via [renderer] config#5416
rlch wants to merge 1 commit intoDioxusLabs:mainfrom
rlch:main

Conversation

@rlch
Copy link
Copy Markdown

@rlch rlch commented Mar 26, 2026

Summary

Adds an optional [renderer] section to Dioxus.toml so projects using dioxus-core with a custom renderer can use dx serve, dx build, dx bundle, and dx fmt — without pulling in any built-in dioxus renderers.

Existing projects without this section are completely unaffected.

Why?

If you use dioxus-core for the VirtualDom/signals/hooks but bring your own rendering pipeline (winit+wgpu+vello, Bevy, etc.), dx currently can't help you — it expects a recognized renderer feature like web or native. This makes the detection configurable.

Example

[renderer]
name = "my-app"
default_platform = "desktop"

[renderer.features]
desktop = []
web = ["my-web-feature"]
ios = ["my-mobile"]
android = ["my-mobile"]

What changed

  • RendererConfig struct in dioxus_config.rsname, default_platform, features map with fallback chain lookup
  • Each platform arm in request.rs checks custom config before the default dioxus feature injection
  • Platform::from_identifier() made pub(crate) for config-driven resolution
  • Schema updated
  • Tests added

Backward compat

RendererConfig defaults to empty via #[serde(default)]. When absent, all code paths are unchanged.

Test plan

  • cargo test -p dioxus-cli -- config::dioxus_config — 5 pass (3 existing + 2 new)
  • cargo clippy -p dioxus-cli -- -D warnings — clean
  • cargo fmt -p dioxus-cli -- --check — clean
  • dx build / dx bundle work with a custom renderer project
  • CI verifies existing examples still build

Add an optional `[renderer]` section to Dioxus.toml that lets projects
using `dioxus-core` with their own renderer declare platform-to-feature
mappings. When present, this overrides the default renderer autodetection
and feature injection. Existing projects without this section are
completely unaffected.

This enables frameworks like Tanzo (winit+wgpu+vello) and Bevy to use
`dx serve`, `dx build`, and `dx bundle` without pulling in dioxus's
built-in renderers.

Changes:
- Add `RendererConfig` struct with `name`, `default_platform`, and
  `features` fields to `DioxusConfig`
- Add `features_for_platform()` with fallback chain support
  (e.g., `["macos", "desktop"]`)
- Consult custom renderer config before default feature injection in
  each platform match arm
- Skip `feature_for_platform_and_renderer()` when custom renderer is
  configured
- Make `Platform::from_identifier()` pub(crate) for config-driven
  platform resolution
- Update schema.json
- Add tests for config parsing and behavior
@rlch rlch requested a review from a team as a code owner March 26, 2026 15:49
@jkelleyrtp jkelleyrtp added the cli Related to the dioxus-cli program label Mar 28, 2026
@rlch
Copy link
Copy Markdown
Author

rlch commented Mar 31, 2026

Tbh don't need this anymore because I ended up making my own CLI for my renderer, but might be useful for the community nonetheless. Feel free to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to the dioxus-cli program

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants