python8u
python8u
TTCTheo's Typesafe Cult
Created by python8u on 4/12/2024 in #questions
I want to get information from the indexedDB and include this in the first render, without delay
The issue is that react code needs to be hydrated before being executed, so you can't get info from localStorage or indexedDB before hydration. The only thing I found that might help is this, https://www.joshwcomeau.com/react/dark-mode/ but it's only for setting CSS variables. chatGPT says there's no way to do this (scroll to bottom): https://chat.openai.com/share/dd719413-5c39-42f1-a695-456971288648 but I find this hard to believe. Surely there must be an idiomatic way to accomplish this?
5 replies
TTCTheo's Typesafe Cult
Created by python8u on 4/11/2024 in #questions
downsides to Using IndexedDB/LocalStorage as a cache?
I'm making a chat app where the user can send/receive messages, which are stored in supabase. I want to cache these messages client-side using IndexedDB or LocalStorage to allow users to instantly view their messages upon page exits and re-entries, without fetching from the db every time. To me, this just seems idiomatic, allowing for instant loading as well as saving bandwidth "localstorage/indexdb can be cleared by client" -> all caches get stale sometimes, just refetch "your localstorage is not accessible on other devices" -> that's fine, just fetch from server like normal "5mb limit for localstorage" -> indexedDB is limited by disk space maybe I'm missing something obvious?
18 replies