React query + chrome extension
gm. first of all, shoutouts to all of you, I used react-query and it's really a pleasure to work with it, the DX is top notch.
I am now working on a chrome extension and I want to use react-query as my state management library.
I do have a basic CQRS architecture like this
chrome extensions have a background process (a service worker) where ideally you can offload the heavy computation. I abstracted the communication between client and background process using trpc
my FE component is calling a trpc method that ends up in the background process. the background process is calling my backend for example and updates my chrome storage
my FE is having right now a wrapper using jotai on chrome storage so it's reactive and it refreshes
I plan to use createAsyncStoragePersister and cache everything in chrome.storage (https://developer.chrome.com/docs/extensions/reference/api/storage)
do you have any examples of this architecture? or anything that is using react-query on an extension? my biggest question is how to use the queryClient on the service worker, where I am outside any react context
Chrome for Developers
chrome.storage | API | Chrome for Developers
0 Replies