Persistent State using islands-router #4646
-
|
I'm trying out islands-router on my SSR + islands app and running into a few issues. The main issue is that context basically does not work: if there are any server components between context provider and user, it does not work (which is the main use-case). So I tried storing signals in a I need a secure enough client-side storage that persists between pages, such as in-memory, for authentication tokens and other less sensitive data. Any ideas on how to achieve this with islands-router or does the islands-router feature need more time to stabilize? Secondary related issue: clicking links that go to the same page (hashtag <--> same page without hashtag) resets displayed signal values to default, even if signals are stored in a Thank you in advance for any help! 🙇 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
For Part 1 -- could you provide some example code? It's hard to understand what you mean. Where are you storing signals in a OnceLock? Where are you using them? Which examples of context don't work? etc. For Part 2 -- I agree that navigating from |
Beta Was this translation helpful? Give feedback.
-
|
Hi @gbj, To clarify: In a Leptos SSR app, With island-router, But also, I'm interested in using island-router to enable sharing signals/state across pages. Since it does not cause a full page reload when navigating between pages, state can be stored in-memory like in server/desktop apps. And state can be persisted as needed to local storage, cookie, or server. ExampleI finally took some time to work on a minimal example and ended up finding a working solution for global, persistent state on client-side using a Here's the repo: https://github.com/CodingFlow/leptos-islands-routing-test/tree/main
Home page (/)
Other page (/other)
I still have one issue I don't have a good solution for:Is there a solution for shared state between islands on the same page, but does not carry over to other pages? |
Beta Was this translation helpful? Give feedback.
Context does work between islands, not sure what you mean. I just added it to your demo and it's fine.