S
SolidJS10mo ago
gsoutz

Passing State between different routes

Do you think this is a good idea to pass data between different pages using solid router. class SessionStore { navigate_filter?: string } export default new SessionStore() , So before navigate('/dashboard'), I do SessionStore.navigate_filter = 'hello', then read the state in dashboard page, how cool is that?
4 Replies
peerreynders
peerreynders10mo ago
What you have to ask yourself: If I was to server-side render this page, would I need to know this information? If you need the info to accurately render the page on the server then it should be somehow expressed directly in the url. Otherwise its volatile/ephemeral, possibly specific to the device and it's OK to use SessionStorage or IndexedDB for that. https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
MDN Web Docs
IndexedDB API - Web APIs | MDN
IndexedDB is a low-level API for client-side storage of significant amounts of structured data, including files/blobs. This API uses indexes to enable high-performance searches of this data. While Web Storage is useful for storing smaller amounts of data, it is less useful for storing larger amounts of structured data. IndexedDB provides a solut...
gsoutz
gsoutzOP10mo ago
Not what I asked, I don't use SessionStorage, I just called my class SessionStore, it's just cache in memory, would that also be ok?
peerreynders
peerreynders10mo ago
Depends entirely on the nature of the information. If it's ephemeral then it's OK. Otherwise it must be referenced in the URL in one way or another.
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server