crxjs

Configure CRXJS Vite plugin for Chrome extension development with content script HMR.

Updated May 23, 2026
One-click install
npx skills add https://github.com/Oatse/CWE-Automation --skill crxjs-oatse
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: crxjs
Source: https://github.com/Oatse/CWE-Automation/tree/main/.agents/skills/crxjs
Command: npx skills add https://github.com/Oatse/CWE-Automation --skill crxjs-oatse

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @crxjs/vite-plugin.

What problem does it solve? Building Chrome extensions with modern frameworks lacks hot module replacement, forcing developers to manually reload the extension and lose state on every code change, especially for content scripts. ## Core Features & Use Cases - True HMR for all extension contexts: Popup, options pages, side panels, and content scripts update via WebSocket without full reloads, while service worker changes trigger automatic extension reload. - Manifest-driven builds: Use defineManifest for type-safe, dynamic Manifest V3 definitions, with CRXJS auto-resolving HTML entry points and generating the extension output. - Dynamic content script injection: Use ?script and ?script&module import suffixes to get resolved paths for chrome.scripting.executeScript, including main world injection. - Use Case: Scaffold a React-based Chrome extension with npm create crxjs@latest, configure the Vite plugin, and iterate on popup and content script code with instant HMR feedback. ## Quick Start Ask the AI to scaffold a new CRXJS Chrome extension project with your preferred framework and configure the Vite plugin with a type-safe manifest.

Frequently Asked Questions about crxjs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up a Chrome extension with HMR using CRXJS?

Run npm create crxjs@latest to scaffold a project, or add @crxjs/vite-plugin to an existing Vite project and register the crx plugin with your manifest in vite.config.ts. Run npm run dev and load the dist directory as an unpacked extension.

CRXJS vs WXT vs Plasmo for Chrome extension development?

CRXJS is a thin Vite plugin offering true content script HMR with minimal abstraction over raw Chrome APIs. WXT adds conventions, built-in utilities, and Safari support, while Plasmo provides the highest-level React-focused abstraction.

Does CRXJS support content script hot module replacement?

Yes, CRXJS provides true HMR for content scripts by generating a loader that injects an HMR preamble and client alongside your script. Main world scripts injected via ?script&module do not get HMR.

Why does CRXJS show WebSocket connection errors like ws://localhost:undefined?

This happens when the dev server port and HMR port mismatch. Fix it by explicitly setting server.port, strictPort, and server.hmr.port to the same value, such as 5173, in your Vite config.

How do I inject content scripts programmatically with CRXJS?

Import the script with the ?script suffix to get a resolved file path, then pass it to chrome.scripting.executeScript. Use ?script&module for main world injection, which runs without HMR.

Which frameworks and Vite versions work with CRXJS?

CRXJS works with React, Vue, Svelte, Solid, and vanilla TypeScript through their standard Vite plugins. It supports Vite versions 3 through 8-beta, with @vitejs/plugin-react recommended over the SWC variant for best HMR compatibility.