wxt
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "wxt" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-ab5a1fc50fc8394206ce42fa7ce10dafed89c3748ea455917007e370f050df34. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Build cross-browser extensions with WXT for Chrome, Firefox, Safari, and Edge. Use this for building browser extensions, React-based Chrome extensions, WXT framework projects, cross-browser extensions, Manifest V3 extensions, Firefox extensions, or TypeScript browser extensions. Covers content scripts, background workers, popup/options pages, storage, messaging, and publishing.
Introduction source: third_party · TerminalSkills · 1.0.0 Reference
SkillPi interpretation
- Audience
- Building a browser extension for Chrome, Firefox, or all browsers Want hot reload during development (not manual reload) Need TypeScript + React/Vue/Svelte in your extension Migrating from Manifest V2 to V3 Want one codebase that targets multiple browsers
- Testing
- Not tested
Browse files
Frontmatter
name: wxt
description: >-
Build cross-browser extensions with WXT — the modern framework for Chrome,
Firefox, Safari, and Edge extensions. Use when someone asks to "build a
browser extension", "Chrome extension with React", "WXT framework", "cross-
browser extension", "manifest v3 extension", "build Firefox extension", or
"browser extension with TypeScript". Covers content scripts, background
workers, popup/options pages, storage, messaging, and publishing.
license: Apache-2.0
compatibility: "Chrome, Firefox, Safari, Edge. Supports React, Vue, Svelte, Solid."
metadata:
author: terminal-skills
version: "1.0.0"
category: development
tags: ["browser-extension", "chrome", "firefox", "wxt", "manifest-v3"]WXT
Overview
WXT is a Vite-based framework for building browser extensions — think "Next.js for extensions." File-based entrypoints, hot reload, TypeScript-first, and it outputs a single extension that works on Chrome (MV3), Firefox (MV2/MV3), Safari, and Edge. No more manually editing manifest.json or reloading the extension after every change.
When to Use
- Building a browser extension for Chrome, Firefox, or all browsers
- Want hot reload during development (not manual reload)
- Need TypeScript + React/Vue/Svelte in your extension
- Migrating from Manifest V2 to V3
- Want one codebase that targets multiple browsers
Instructions
Setup
npx wxt@latest init my-extension
cd my-extension
npm install
npm run dev # Opens Chrome with hot-reloading extension
Project Structure
my-extension/
├── entrypoints/
│ ├── popup/ # Popup UI (click extension icon)
│ │ ├── index.html
│ │ ├── main.tsx
│ │ └── App.tsx
│ ├── options/ # Options page
│ │ ├── index.html
│ │ └── main.tsx
│ ├── content.ts # Content script (runs on web pages)
│ └── background.ts # Service worker (background logic)
├── public/
│ └── icon/
│ ├── 16.png
│ ├── 48.png
│ └── 128.png
├── wxt.config.ts
└── package.json
Content Script
// entrypoints/content.ts — Runs on matched web pages
/**
* Content scripts have access to the DOM of the page.
* Define which URLs to match with the `matches` export.
*/
export default defineContentScript({
matches: ["*://*.github.com/*"], // Run on GitHub pages
main() {
// Add a custom button to every GitHub PR page
const prHeader = document.querySelector(".gh-header-actions");
if (prHeader) {
const btn = document.createElement("button");
btn.textContent = "🤖 AI Review";
btn.className = "btn btn-sm";
btn.onclick = async () => {
const diff = document.querySelector(".diff-view")?.textContent;
// Send to background for API call
const review = await browser.runtime.sendMessage({
type: "REVIEW_PR",
diff: diff?.slice(0, 5000),
});
alert(review.summary);
};
prHeader.prepend(btn);
}
},
});
Background Service Worker
// entrypoints/background.ts — Persistent background logic
/**
* Service worker handles API calls, alarms, and message routing.
* No DOM access here — communicate with content scripts via messaging.
*/
export default defineBackground(() => {
// Handle messages from content scripts
browser.runtime.onMessage.addListener(async (msg, sender) => {
if (msg.type === "REVIEW_PR") {
const response = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${await storage.getItem("local:apiKey")}`,
},
body: JSON.stringify({
model: "gpt-4o",
messages: [{ role: "user", content: `Review this diff:\n${msg.diff}` }],
}),
});
const data = await response.json();
return { summary: data.choices[0].message.content };
}
});
// Periodic tasks with alarms
browser.alarms.create("check-notifications", { periodInMinutes: 5 });
browser.alarms.onAlarm.addListener(async (alarm) => {
if (alarm.name === "check-notifications") {
// Check for updates, show badge
const count = await checkNotifications();
if (count > 0) {
browser.action.setBadgeText({ text: String(count) });
}
}
});
});
Popup UI (React)
// entrypoints/popup/App.tsx — Extension popup with React
import { useState, useEffect } from "react";
export default function App() {
const [apiKey, setApiKey] = useState("");
const [saved, setSaved] = useState(false);
useEffect(() => {
storage.getItem<string>("local:apiKey").then((key) => {
if (key) setApiKey(key);
});
}, []);
const save = async () => {
await storage.setItem("local:apiKey", apiKey);
setSaved(true);
setTimeout(() => setSaved(false), 2000);
};
return (
<div style={{ width: 300, padding: 16 }}>
<h2>🤖 AI PR Reviewer</h2>
<input
type="password"
value={apiKey}
onChange={(e) => setApiKey(e.target.value)}
placeholder="OpenAI API Key"
style={{ width: "100%" }}
/>
<button onClick={save} style={{ marginTop: 8 }}>
{saved ? "✅ Saved!" : "Save Key"}
</button>
</div>
);
}
Build for Multiple Browsers
# Development (Chrome with hot reload)
npm run dev
# Development for Firefox
npm run dev:firefox
# Build for all browsers
npm run build # Chrome MV3
npm run build:firefox # Firefox MV2/MV3
# Zip for store submission
npm run zip
npm run zip:firefox
Examples
Example 1: Build a productivity extension
User prompt: "Build a Chrome extension that blocks distracting websites during focus time."
The agent will create a WXT extension with a popup for configuring blocked sites and focus timer, a content script that shows a block page on matched domains, and background alarms for timer management.
Example 2: Content enhancement extension
User prompt: "Build an extension that adds AI-powered summaries to any article page."
The agent will create a content script that detects article content, a floating sidebar UI, and background API calls to summarize text.
Guidelines
- File-based entrypoints — file name and location determine the extension component
- *`browser.` API** — WXT polyfills Chrome and Firefox differences automatically
storagehelper — type-safe extension storage withstorage.getItem/setItem- Hot reload works —
npm run devreloads content scripts and popup on save - MV3 service workers — background scripts are service workers (no persistent state)
matchesfor content scripts — define URL patterns where scripts should inject- Message passing — content script ↔ background communication via
browser.runtime.sendMessage - One codebase, all browsers — build targets handle manifest differences
- Icons at 16/48/128px — required for Chrome Web Store
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- WXT 框架提供跨浏览器扩展开发的一站式解决方案,覆盖 Chrome、Firefox、Safari、Edge
- 支持 Manifest V3、TypeScript、React/Vue/Svelte,解决热重载和多平台构建等核心痛点
Highlights
- 触发词覆盖全面,包括“构建浏览器扩展”、“WXT 框架”、“跨浏览器扩展”等多种用户常见表达
Highlights
- 文档结构完整,包含从初始化到构建发布的完整流程
- 提供详细的代码示例和项目结构说明,便于用户快速上手
Highlights
- 提供了完整的开发、构建、打包命令和关键组件实现示例
- 工具链明确,参数正确,覆盖主要异常场景
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 38, 40 -
Accounts, secrets or authorization
Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.
Mentioned in main document · lines 115, 148, 152, 158, 168
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- api.openai.com
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.