Skip to content

chmousset/dioxus-websocket-hooks

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dioxus-websocket-hooks

Dioxus hooks for websocket connections

use dioxus_websocket_hooks::{use_ws_context, use_ws_context_provider_json};

fn app(cx: Scope) -> Element {
    use_ws_context_provider_json(&cx, "wss://echo.websocket.events", move |msg| {
        // Handle incoming ws message, e.g. store it in shared state
    });

    ...
}

fn ExampleComponent(cx: Scope) -> Element {
    let ws = use_ws_context(&cx);

    cx.render(rsx! (
        button { onclick: move |_| ws.send_json(&"hello"), "Submit" }
    ))
}

Examples

See cargo examples

Samples make use of fermi for state management.

About

Dioxus hooks for websocket connections

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 91.1%
  • Nix 8.9%