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•14mo 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
Mael•14mo 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•14mo ago
I dont' think so - that's for a diff API
Mael
Mael•14mo 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•14mo ago
it use window.postMessage
Mael
Mael•14mo ago
Great
lab
lab•14mo ago
which if used with contentscript will allow you to comm w page check the example for more deet
Mael
Mael•14mo ago
Thanks!
Mael
Mael•14mo 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?