Maybe I haven't found a library or any class that does this, could someone help me with this?
I actually found some documents online that seemed to be about that, but I couldn't quite understand.
I'm new to Rust and Yew even more! but I loved the possibilities and the tool.
You can do this using web-sys which provides bindings to the JavaScript Storage object.
You can find the documentation for that here.
Here's how you get access to the storage object from the window and then use it to get the value of a key.
// note the double unwrap because local_storage() returns Result<Option<...>, ...>
let local_storage = web_sys::window().unwrap().local_storage().unwrap().unwrap();
let value = local_storage.get_item("key").unwrap();
Note: If you're using yew-stdweb then you should use the stdweb equivalent.
There are also yew abstractions over local (and session) storage which can be used.
Most helpful comment
You can do this using
web-syswhich provides bindings to the JavaScriptStorageobject.You can find the documentation for that here.
Here's how you get access to the storage object from the window and then use it to get the value of a key.
Note: If you're using
yew-stdwebthen you should use thestdwebequivalent.