Using @plasmohq/messaging separately?

I have a web app that has a signup/signin process. I want to "sync" the auth state between the extension and the page. I was thinking maybe I can send a relay message from my web app using this package with a content script that's only injected on that webpage and handle it from there. The web app does NOT use plasmo but it's a plain react app, but I was wondering if I can just install the messaging package and use it there. Is this possible? Any other solution you guys have found? Thanks!
9 Replies
lab
lab•2y ago
Yes this is intended - note that you must ensure not to include submodules that use the chrome API such as the index or background The messaging example should demonstrate the use of the relay from within a webapp
Mael
MaelOP•2y ago
You're the goat. @louis do I need to modify the "externally_connectable" part of the manifest for the relays to work?
lab
lab•2y ago
I dont' think so - that's for a diff API
Mael
MaelOP•2y ago
The "externally_connectable" manifest property declares which extensions and web pages can connect to your extension via runtime.connect and runtime.sendMessage.
so relays do not use sendMessage?
lab
lab•2y ago
it use window.postMessage
Mael
MaelOP•2y ago
Great
lab
lab•2y ago
which if used with contentscript will allow you to comm w page check the example for more deet
Mael
MaelOP•2y ago
Thanks!
Mael
MaelOP•2y ago
This is what I'm intending to do: the first screenshot is the content script. The second one is the background/messages/auth.ts file. The third one is the web app (different app, different repo). But I'm not receiving any messages. Am I missing something?
Want results from more Discord servers?
Add your server