Svelte
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 example
new-svelte
Use the Svelte starter when you want a framework-first extension UI with minimal setup.
Usage with an existing extension
Install Svelte:
For explicit setup in an existing project, install the Svelte loader too:
Development behavior
When Svelte is detected, Extension.js:
- enables
.sveltefile resolution - wires the Svelte loader into the JS framework pipeline
- applies Svelte client aliases such as
svelte,svelte/store, andsvelte/reactivity
If optional tooling is missing, Extension.js can install what it needs and ask for a restart.
Usage examples
In an extension page
In a content script
For content scripts, create a mount node and return a cleanup from your default export so Extension.js can 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
- Learn more about TypeScript support.
- Review the content-script contract in Content scripts.
