Best state management for react chrome extensions?

Im looking into making a chrome extension. It will be handling a somewhat complex state, shared between background scripts, and the popup UI for the user. So my question is, how do i handle shared typesafe and persisting state across script in a chrome extension? Can't seem to find any good resources on this. Will i need to have different states in UI and background script, and then use some kind of bridge between them? Sounds like a environment that will slow development time drastically...
9 Replies
Gaden
GadenOP2y ago
https://github.com/tshaddix/webext-redux This is my best lead so far But am i really going with redux??? Idk... If i cant find any better solution i might
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Gaden
GadenOP2y ago
I would use zustand if i found an easy way of having shared state across all scripts In an extension, afaik, every script, is a different process in js So the js running in your popup UI, is not the same as running in the background scripts
Gaden
GadenOP2y ago
Thats why this have this weird proxy layout to solve it
Gaden
GadenOP2y ago
Buts its for redux This doenst look like it got type safe So aint gonna make it for me
Gary, el Pingüino Artefacto
Jotai if its small
Gaden
GadenOP2y ago
Cant seem to find a way to share jotai state across processes Actually this might support type safety. I will give it a test and see if it works. If it works i will have to go with redux for this project Okay doesnt seem like it That project is a mess ... Still looking for the best state management for chrome extensions Im now considering not using a state manager, and having my background script being the only source of truth And then writing a bridge between background and popup to render the state
ironnator
ironnator2y ago
Maybe local storage? Lol might depend on what you’re storing in state
Gaden
GadenOP2y ago
it just doesnt scale really well with expanding complex state. and i would have to write custom code to handle typesafety
Want results from more Discord servers?
Add your server