9 releases (breaking)

Uses new Rust 2024

0.7.0 Jan 17, 2026
0.6.1 Dec 30, 2025
0.5.0 May 7, 2025
0.4.0 Dec 17, 2024
0.1.0 Feb 12, 2024

#556 in Game dev

MIT/Apache

49KB
333 lines

bevy_ehttp

Crates.io Documentation MIT/Apache 2.0

A ehttp Bevy Plugin that works both on native and on WASM.

Simple request will invoke OnResponseString(pub Result<Response, String>) event once completed.

There is also option to call typed request that will allow to deserialize response to given type by using RequestBundle<T>. More details available in typed.rs example.

Example

use bevy::{prelude::*, time::common_conditions::on_timer};
use bevy_ehttp::prelude::*;

fn main() {
    App::new()
        .add_plugins((MinimalPlugins, HttpPlugin))
        .add_systems(
            Update,
            send_request.run_if(on_timer(std::time::Duration::from_secs(1))),
        )
        .add_observer(on_response)
        .run();
}

fn send_request(mut commands: Commands) {
    commands.spawn(HttpRequest::get("https://api.ipify.org?format=json"));
}

fn on_response(t: On<OnResponseString>) {
    match &**t {
        Ok(response) => println!("[{:?}]: {:?}", t.url(), response.text()),
        Err(e) => println!("response error: {:?}", e),
    }
}

Thanks

Big thanks to the creators of the Bevy Engine and to the foxzool user for creating bevy_http_client that this plugin is based on.

License

bevy_ehttp is dual-licensed under MIT and Apache 2.0 at your option.

Bevy compatibility table

Bevy version Crate version
0.18 0.7
0.17 0.6
0.16 0.5
0.15 0.4
0.14 0.3
0.13 0.2
0.12 0.1

Dependencies

~25–44MB
~595K SLoC