Ship smaller extension UI bundles while keeping a React-like developer experience and fast local iteration. Extension.js detects Preact from your dependencies. It configures JSX/TSX transforms, React compatibility aliases, and fast-refresh support automatically. Your React imports map to Preact through these aliases.Documentation Index
Fetch the complete documentation index at: https://extension.js.org/llms.txt
Use this file to discover all available pages before exploring further.
When Preact is a good fit
- You want smaller UI bundle size for popup/sidebar/new tab surfaces.
- You like React-style components but want a lighter runtime.
- You are optimizing extension startup and UI responsiveness on lower-end devices.
Template examples
new-preact

content-preact

Usage with an existing extension
Add Preact to an existing extension with the steps below.Installation
Install the required dependencies: Preact ships its own TypeScript types, so you do not need a separate@types/preact package.
Configuration
Extension.js expects Preact files to use the following file extensions:- If you do not enable TypeScript:
*.jsx - If you enable TypeScript:
*.tsx
Development behavior
When Extension.js detects Preact, it configures:- Compatibility aliases (for example,
react→preact/compat). - JSX handling tuned for Preact.
- Refresh integration in development using
@rspack/plugin-preact-refresh.
Troubleshooting
- Missing refresh dependency warning: Install
@rspack/plugin-preact-refresh(and related packages if prompted). - Prompt to restart after install: Stop and rerun
extension devso the dev server can reload refresh wiring cleanly. - No Preact integration detected: Confirm
preactappears independenciesordevDependencies.
Usage examples
In a new tab extension
To use Preact in a new tab extension, include it as a<script> in your HTML file:
In a content_script file
For content scripts, inject Preact into the page by creating an HTML element and rendering into it:
Next steps
- Learn more about TypeScript support.
- Explore how Extension.js handles Sass modules.

