Skip to content
Discussion options

You must be logged in to vote

Here are some good options:

  1. use_local_storage from the leptos-use library
  2. gloo_storage from gloo, which offers a variety of Rust-friendly wrappers for web APIs
  3. Using the web-sys Local Storage directly as in the todomvc example in this repo
    pub fn new() -> Self {
    let starting_todos =
    window()
    .local_storage()
    .ok()
    .flatten()
    .and_then(|storage| {
    storage.get_item(STORAGE_KEY).ok().flatten().and_then(
    |value| serde_json::from_str::<Vec<Todo>>(&value).ok(),
    )
    })
    .unwrap_or_default();

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@qknight
Comment options

Answer selected by qknight
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants