Content Scripts UI – Plasmo

Plasmo has first-class support for mounting React, Svelte3, or Vue3 components into the current webpage. This feature is called content scripts UI (CSUI).

An extension can have as many CSUI as needed, with each CSUI targeting a group of webpages or a specific webpage by exporting the config object. To start injecting UI using React:

  1. Create a content.tsx
  2. Export a default React component
  3. Profit 🎉

See with-content-scripts-ui (opens in a new tab) for a full example.

Config

Content scripts UI are a subset of content scripts. Thus, you can export a config object just as you would a regular Plasmo content script.

How does Plasmo CSUI work?

TL;DR: Plasmo creates a Shadow DOM (opens in a new tab) and mounts your exported component onto it. This isolation technique prevents the web page's style from affecting your component's styling and vice-versa.

For more details, please see the Life Cycle of Plasmo CSUI.

Content ScriptsLife Cycle