Skip to main content
Build extension UIs with Svelte components while keeping Extension.js in charge of the framework wiring. Extension.js detects Svelte from your project dependencies and configures .svelte resolution, loader setup, and Svelte client aliases automatically.

When Svelte is a good fit

  • You want a smaller runtime for popup, options, sidebar, or new-tab UIs.
  • You prefer component-first authoring with concise syntax.
  • You want a framework option that works for both extension pages and content-script UI mounts.

Template examples

new-svelte

new-svelte template screenshot Use the Svelte starter when you want a framework-first extension UI with minimal setup.
Repository: extension-js/examples/new-svelte

content-svelte

content-svelte template screenshot Inject Svelte components into web pages through content scripts.
Repository: extension-js/examples/content-svelte

Usage with an existing extension

Install Svelte:
For explicit setup in an existing project, install the Svelte loader too:

Development behavior

When Extension.js detects Svelte, it:
  • Enables .svelte file resolution.
  • Configures the Svelte loader in the JS framework pipeline, with hot reload enabled in development so edited components update without a full page reload.
  • Applies Svelte client aliases (for example, svelte, svelte/store, and svelte/reactivity).
If your project lacks optional tooling, Extension.js installs what it needs and asks for a restart.

Usage examples

In an extension page

In a content_script file

For content scripts, create a mount node and return a cleanup function from your default export. This lets Extension.js remount safely in development:

Best practices

  • Keep Svelte components focused on UI and move browser API orchestration to dedicated modules.
  • In content scripts, always return cleanup so remount behavior stays predictable.
  • Use Svelte for extension pages first, then expand to content-script UI once the feature boundary is clear.

Next steps