How to pass data in contents file?
Hi everyone, I just learned to use plasmo
I read this section in the docs
https://docs.plasmo.com/framework/content-scripts-ui,
So I created a Content Scripts UI file called index.tsx.
When the index.ts file in the background folder calls the windowChanger function in the content file in index.ts, how to transfer the data generated by the PlasmoMainUI component in the index.tsx file and render it on the webpage?
I hope someone can tell me, thank you very much
4 Replies
You will need to use the relay API for this
https://docs.plasmo.com/framework/messaging#relay-flow
Example at this link
contents/plasmo.ts
import type { PlasmoCSConfig } from "plasmo"
import { relayMessage } from "@plasmohq/messaging"
export const config: PlasmoCSConfig = {
matches: ["http://www.plasmo.com/*"] // Only relay messages from this domain
}
relayMessage({
name: "ping"
})
Why does this assignment of name: "ping" prompt: Cannot assign type 'string' to type 'never'.
Plasmo Docs
Messaging API – Plasmo
The Plasmo messaging API is a powerful tool for sending real-time messages between different parts of your extension.
@HUTUTU has reached level 1. GG!
Why does this assignment of name: "ping" prompt: Cannot assign type 'string' to type 'never'.You will need to run the dev server for the internal typing to be applied