Crates.io | leptos_ws |
lib.rs | leptos_ws |
version | |
source | src |
created_at | 2024-08-31 10:54:08.628069 |
updated_at | 2024-12-09 15:13:59.888888 |
description | Leptos WS is a Websocket for the Leptos framework to support updates coordinated from the Server |
homepage | |
repository | https://github.com/TimTom2016/leptos_ws |
max_upload_size | |
id | 1358735 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Leptos Websocket provides server signals for Leptos, keeping them in sync with the server through WebSockets. This enables real-time updates on the UI controlled by the server.
Add the following to your Cargo.toml
:
[dependencies]
leptos_ws = "0.7.0-rc1"
serde = { version = "1.0", features = ["derive"] }
[features]
ssr = ["leptos_ws/ssr", "leptos_ws/axum"]
use leptos::prelude::*;
use serde::{Deserialize, Serialize};
#[component]
pub fn App() -> impl IntoView {
// Connect to WebSocket
leptos_ws::provide_websocket("http://localhost:3000/ws");
// Create server signal
let count = leptos_ws::ServerSignal::new("count".to_string(), 0 as i32).unwrap();
view! {
<h1>"Count: " {move || count.get().to_string()}</h1>
}
}
Server-side implementation requires additional setup. Refer to the example for detailed examples.
ssr
: Enable server-side rendering support.axum
: Enable integration with the Axum web framework.For more detailed information, check out the API documentation.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.