Skip to content

Installation

Bootstrap a new project, start from scratch, or migrate an existing project.

Bootstrap Project

Run the init command, and follow the instructions.

sh
pnpm dlx wxt@latest init
sh
bunx wxt@latest init
sh
npx wxt@latest init
sh
# Use NPM initially, but select Yarn when prompted
npx wxt@latest init

Starter Templates:

TypeScript LogoVanilla
Vue LogoVue
React LogoReact
Svelte LogoSvelte
Solid LogoSolid

All templates use TypeScript by default. To use JavaScript, change the file extensions.

Demo

wxt init demo

Once you've run the dev command, continue to Next Steps!

From Scratch

  1. Create a new project
    sh
    cd my-project
    pnpm init
    sh
    cd my-project
    bun init
    sh
    cd my-project
    npm init
    sh
    cd my-project
    yarn init
  2. Install WXT:
    sh
    pnpm i -D wxt
    sh
    bun i -D wxt
    sh
    npm i -D wxt
    sh
    yarn add --dev wxt
  3. Add an entrypoint, my-project/entrypoints/background.ts:
    ts
    export default defineBackground(() => {
      console.log('Hello world!');
    });
  4. Add scripts to your package.json:
    json
    {
      "scripts": {
        "dev": "wxt", 
        "dev:firefox": "wxt -b firefox", 
        "build": "wxt build", 
        "build:firefox": "wxt build -b firefox", 
        "zip": "wxt zip", 
        "zip:firefox": "wxt zip -b firefox", 
        "postinstall": "wxt prepare"
      }
    }
  5. Run your extension in dev mode
    sh
    pnpm dev
    sh
    bun run dev
    sh
    npm run dev
    sh
    yarn dev
    WXT will automatically open a browser window with your extension installed.

Next Steps