> ## 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.

> ## Agent Instructions
> Extension.js needs Node.js 22.12 or newer; Node.js 18 and 20 do not work. It also runs on Deno 2.5+ and Bun 1.2+.
> The default browser target is chromium and a build lands in dist/<browser>, so dist/chromium by default. extension build writes a zip only when --zip is passed.
> Prefix a manifest key with a browser name when browsers differ. chromium: covers every Chromium-family target and Safari builds read it too. Since 4.1.19 chrome: means Chrome alone and edge: means Edge alone.
> Write one background.service_worker in manifest.json instead of hand-writing per-browser background keys; Extension.js converts it for each browser.
> package.json or deno.json marks the project root, not manifest.json. A config file is optional, and only extension.config.js, .mjs and .cjs are loaded, never .ts.
> The bundler is Rspack, extended through the config hook in extension.config.js. A project needs no separate bundler config file.
> Use --no-browser to skip the browser launch; --no-runner no longer exists and --no-open still launches the browser. Use --output for machine output; --format and --wait-format are deprecated.

# Extension templates for React, Vue, and more

> Scaffold a browser extension from official Extension.js templates for React, Preact, Vue, Svelte, TypeScript, WebAssembly, and vanilla JavaScript.

Start faster by scaffolding extensions from official templates instead of building folder structure and configuration from scratch.

## Template capabilities

* **Ready project structure:** Start with a working manifest, scripts, and source layout.
* **Stack-specific setup:** Choose templates by framework and runtime needs.
* **Faster onboarding:** Move from idea to runnable extension in minutes.
* **Consistent defaults:** Reduce setup drift across projects and team members.

## Quick usage

```bash npm theme={null}
npx extension@latest create my-extension --template=<slug>
```

```bash pnpm theme={null}
pnpx extension@latest create my-extension --template=<slug>
```

```bash yarn 2+ theme={null}
yarn dlx extension@latest create my-extension --template=<slug>
```

```bash bun theme={null}
bunx extension@latest create my-extension --template=<slug>
```

```bash deno theme={null}
deno run -A npm:extension@latest create my-extension --template=<slug>
```

Replace `<slug>` with the template you want to start from.

[Extension.js: create from a template](https://www.youtube-nocookie.com/embed/DFbseARH84I?rel=0)

## Available templates

Each template scaffolds a minimal, runnable extension with a working `manifest.json`. Expand one for what it gives you, the exact command, and a walkthrough.

> [accordion] JavaScript
>
> A clean ES modules baseline with no compile step. The template wires up `manifest.json`, a sidebar panel, a background script, and a content script entry point, so you can run `extension dev` and start iterating immediately. Choose it when you want the smallest possible setup.
>
> ```bash theme={null}
> npx extension@latest create my-extension --template=javascript
> ```
>
> Browse the full source on GitHub: [extension-js/templates/javascript](https://github.com/extension-js/templates/tree/main/examples/javascript)
>
> [Extension.js: JavaScript template](https://www.youtube-nocookie.com/embed/Ryjuq2o-kzc?rel=0)

> [accordion] TypeScript
>
> Static types across the sidebar panel, content, and background scripts, with `chrome` and `browser` API typings configured. Catch manifest, messaging, and permission bugs at compile time instead of in the browser console. This is the default when you omit `--template`.
>
> ```bash theme={null}
> npx extension@latest create my-extension --template=typescript
> ```
>
> Browse the full source on GitHub: [extension-js/templates/typescript](https://github.com/extension-js/templates/tree/main/examples/typescript)
>
> [Extension.js: TypeScript template](https://www.youtube-nocookie.com/embed/UX91cqUH2DU?rel=0)

> [accordion] Svelte
>
> Compile-time UI with single-file `.svelte` components and a minimal runtime footprint. The template scaffolds a sidebar panel and a content script, plus the build configuration needed for HMR-friendly Svelte authoring inside an extension context.
>
> ```bash theme={null}
> npx extension@latest create my-extension --template=svelte
> ```
>
> Browse the full source on GitHub: [extension-js/templates/svelte](https://github.com/extension-js/templates/tree/main/examples/svelte)
>
> [Extension.js: Svelte template](https://www.youtube-nocookie.com/embed/RgMo9t-oLL4?rel=0)

> [accordion] Vue
>
> A progressive setup with `.vue` single-file components, scaffolded as a sidebar panel plus a content script. The template handles SFC compilation and reload behavior, so you can focus on UI.
>
> ```bash theme={null}
> npx extension@latest create my-extension --template=vue
> ```
>
> Browse the full source on GitHub: [extension-js/templates/vue](https://github.com/extension-js/templates/tree/main/examples/vue)
>
> [Extension.js: Vue template](https://www.youtube-nocookie.com/embed/x55b3Md2zIY?rel=0)

> [accordion] Preact
>
> The same component model as React with a 3kB runtime, configured with the standard `preact/compat` aliasing so most React libraries keep working. A good fit when bundle size matters, especially for content scripts injected into other people's pages.
>
> ```bash theme={null}
> npx extension@latest create my-extension --template=preact
> ```
>
> Browse the full source on GitHub: [extension-js/templates/preact](https://github.com/extension-js/templates/tree/main/examples/preact)
>
> [Extension.js: Preact template](https://www.youtube-nocookie.com/embed/VcAPgX8KHgI?rel=0)

> [accordion] React
>
> A component-based UI baseline with full Manifest V3 support. The sidebar panel and content script ship as React entry points with hot module replacement wired up. Edit a component and see it update without reloading the extension by hand.
>
> ```bash theme={null}
> npx extension@latest create my-extension --template=react
> ```
>
> Browse the full source on GitHub: [extension-js/templates/react](https://github.com/extension-js/templates/tree/main/examples/react)
>
> [Extension.js: React template](https://www.youtube-nocookie.com/embed/mRgWdPgv1hE?rel=0)

## How it works

When you run `create --template=<slug>`, Extension.js fetches the selected template, scaffolds the project files, and optionally installs dependencies.

Only the `javascript` template ships inside the CLI, so it scaffolds offline with no network call. The default when you omit `--template` is `typescript`, which downloads like every other name. When that download fails, `create` falls back to the bundled `javascript` template and names the network error. A set `EXTENSION_CREATE_TEMPLATE_URL` turns that fallback off, so a failed override fails the run and names the variable.

The catalog holds 7 groups and 60 templates: starters, sidebar, content scripts, new tab, toolbar action, DevTools panel, and special folders. Run `extension create --help` to see every name.

A name outside the catalog fails with `E_TEMPLATE_NOT_FOUND` and creates nothing. A failed download is reported as a download error instead, so a network problem never reads like a typo.

### Reproducible scaffolds

The template corpus is pinned to an immutable commit of the templates repository. Two scaffolds of the same template always produce the same files, and a shipped CLI never tracks a moving branch.

You can point at a different corpus:

```bash theme={null}
# A branch, tag, or commit SHA of extension-js/templates
EXTENSION_CREATE_TEMPLATE_REF=main npx extension@latest create my-extension --template=react

# Override the archive URL entirely
EXTENSION_CREATE_TEMPLATE_URL=https://example.com/examples.zip npx extension@latest create my-extension --template=react
```

`EXTENSION_CREATE_TEMPLATE_REF` accepts a branch, a tag, or a commit SHA. Setting it to `main` restores the floating branch behavior.

### Scaffold from a URL

`--template` also accepts a GitHub URL or a ZIP URL in place of a catalog name:

```bash theme={null}
npx extension@latest create my-extension --template=https://github.com/extension-js/templates/tree/main/examples/content
```

From 4.1.19, template URLs and `EXTENSION_CREATE_TEMPLATE_URL` must use `https://`. `create` refuses `http://` unless you set `EXTENSION_ALLOW_HTTP_TEMPLATE=true`.

## More templates

Find official template sources in the templates repository:

* [extension-js/templates](https://github.com/extension-js/templates/tree/main/examples)

Template folder names map directly to `--template=<slug>`.

## Best practices

* Use templates to scaffold your project quickly.
* Start with a template that matches a technology stack you already know.
* Choose the browser extension context that best fits your project requirements.

## Next steps

* Learn how [browser runners](https://extension.js.org/docs/browsers/browsers-available.md) help you validate extension behavior.
* Learn how Extension.js handles [Environment variables](https://extension.js.org/docs/features/environment-variables.md).

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.