MCPcopy Index your code
hub / github.com/Synphonyte/leptos-bevy-canvas

github.com/Synphonyte/leptos-bevy-canvas @v0.6.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.6.0 ↗ · + Follow
110 symbols 161 edges 42 files 12 documented · 11% updated 14d agov0.6.0 · 2026-06-24★ 140
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Leptos Bevy Canvas

Crates.io Docs MIT/Apache 2.0 Build Status

Embed an idiomatic Bevy app inside your Leptos app.

Send and Receive Messages Messages Demo

Sync Bevy Queries Query Sync Demo

Features

  • Easy to use - Simply embed your Bevy app inside your Leptos app with the BevyCanvas component.
  • Idiomatic - This crate doesn't want you to do anything differently in the way you write your Bevy app or your Leptos app. It just gives you the tools for them to communicate.
  • Messages - Send messages in either or both directions between your Bevy app and your Leptos app.
  • Resource signals - Synchronize Bevy Resources with RwSignals in your Leptos app.
  • Query signals - Synchronize Bevy Querys with RwSignals in your Leptos app.
  • State signals - Synchronize Bevy States with RwSignals in your Leptos app.

Example

use bevy::prelude::*;
use leptos::prelude::*;
use leptos_bevy_canvas::prelude::*;

#[derive(Message)]
pub struct TextMessage {
    pub text: String,
}

#[component]
pub fn App() -> impl IntoView {
    // This initializes a sender for the Leptos app and
    // a receiver for the Bevy app
    let (text_message_sender, bevy_text_receiver) = message_l2b::<TextMessage>();

    let on_input = move |evt| {
        // send the message over to Bevy
        text_message_sender
            .send(TextMessage { text: event_target_value(&evt) })
            .ok();
    };

    view! {
        <input type="text" on:input=on_input />

        <BevyCanvas
            init=move || {
                // Pass the receiver into the Bevy app initialization
                init_bevy_app(bevy_text_receiver)
            }

            {..}
            width="300"
            height="500"
        />
    }
}

// In Bevy it ends up just as a normal message
pub fn set_text(
    mut message_reader: MessageReader<TextMessage>,
) {
    for message in message_reader.read() {
        // do something with the message
    }
}

// This initializes a normal Bevy app
fn init_bevy_app( text_receiver: BevyMessageReceiver<TextMessage>) -> App {
    let mut app = App::new();
    app
        .add_plugins(
            DefaultPlugins.set(WindowPlugin {
                primary_window: Some(Window {
                    // "#bevy_canvas" is the default and can be
                    // changed in the <BevyCanvas> component
                    canvas: Some("#bevy_canvas".into()),
                    ..default()
                }),
                ..default()
            }),
        )
        // import the message here into Bevy
        .import_message_from_leptos(text_receiver)
        .add_systems(Update, set_text);

    app
}

Please check the examples to see how to synchronize a Resource or a Query.

Compatibility

Crate version Compatible Leptos version Compatible Bevy version
0.6 0.8 0.19
0.5 0.8 0.18
0.4 0.8 0.17
0.3 0.8 0.16
0.1, 0.2 0.7 0.15

Extension points exported contracts — how you extend this code

LeptosChannelMessageSender (Interface)
This is a trait that is implemented by a Leptos message sender. [2 implementers]
src/messages/leptos/traits.rs
LeptosBevyApp (Interface)
Adds synchronization methods to the Bevy app [1 implementers]
src/app_extension.rs
HasReceiver (Interface)
(no doc)
src/traits.rs
QueryDataOwned (Interface)
(no doc)
src/queries.rs
HasSender (Interface)
(no doc)
src/traits.rs

Core symbols most depended-on inside this repo

clone
called by 19
src/queries.rs
send
called by 8
src/messages/leptos/traits.rs
tx
called by 5
src/messages/leptos/mod.rs
clone
called by 2
src/signal_synced.rs
signal_synced
called by 2
src/signal_synced.rs
init_rw_signal_from_receiver
called by 2
src/utils.rs
import_message_from_leptos
called by 2
src/app_extension.rs
check_compat_table
called by 2
docs/check_version_in_docs.py

Shape

Function 46
Method 30
Class 25
Interface 5
Enum 4

Languages

Rust97%
Python3%

Modules by API surface

src/systems.rs12 symbols
src/signal_synced.rs10 symbols
src/app_extension.rs7 symbols
examples/unidir_messages/src/leptos_app.rs7 symbols
src/plugin.rs6 symbols
src/messages/leptos/mod.rs6 symbols
src/messages/bevy/mod.rs6 symbols
src/queries.rs4 symbols
examples/synced_bevy_query/src/bevy_app/components.rs4 symbols
examples/loading_screen/src/bevy_app/components.rs4 symbols
src/messages/mod.rs3 symbols
examples/unidir_messages/src/bevy_app/systems.rs3 symbols

For agents

$ claude mcp add leptos-bevy-canvas \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page