Convert Figma logo to code with AI

crxjs logochrome-extension-tools

Build cross-browser extensions with native HMR and zero-config setup

3,927
245
3,927
24

Top Related Projects

77,503

Next generation frontend tooling. It's fast!

Quick Overview

CRXJS Chrome Extension Tools is a set of utilities designed to simplify the development of Chrome extensions using modern web technologies. It provides a seamless integration with Vite, allowing developers to build extensions using frameworks like React, Vue, and Svelte with hot module replacement (HMR) support.

Pros

  • Enables the use of modern web frameworks and tools for Chrome extension development
  • Supports hot module replacement (HMR) for faster development cycles
  • Integrates well with Vite, leveraging its speed and efficiency
  • Simplifies the build process for Chrome extensions

Cons

  • Limited to Chrome extensions, not applicable for other browser extension development
  • Requires familiarity with Vite and modern JavaScript tooling
  • May have a learning curve for developers used to traditional extension development methods
  • Documentation could be more comprehensive for advanced use cases

Code Examples

  1. Basic Vite configuration for a Chrome extension:
// vite.config.js
import { defineConfig } from 'vite'
import { crx } from '@crxjs/vite-plugin'
import manifest from './manifest.json'

export default defineConfig({
  plugins: [crx({ manifest })],
})
  1. Using React with CRXJS:
// popup.jsx
import React from 'react'
import ReactDOM from 'react-dom/client'
import Popup from './Popup.jsx'

ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <Popup />
  </React.StrictMode>
)
  1. Content script injection:
// content.js
console.log('Content script loaded')

document.body.style.backgroundColor = 'lightblue'

Getting Started

  1. Install CRXJS in your project:

    npm install @crxjs/vite-plugin -D
    
  2. Create a manifest.json file for your extension.

  3. Set up your vite.config.js file:

    import { defineConfig } from 'vite'
    import { crx } from '@crxjs/vite-plugin'
    import manifest from './manifest.json'
    
    export default defineConfig({
      plugins: [crx({ manifest })],
    })
    
  4. Run the development server:

    npm run dev
    
  5. Load the dist folder as an unpacked extension in Chrome for testing.

Competitor Comparisons

77,503

Next generation frontend tooling. It's fast!

Pros of Vite

  • Broader ecosystem support and larger community
  • Faster build times and hot module replacement
  • More flexible and can be used for various project types beyond extensions

Cons of Vite

  • Requires additional configuration for Chrome extension development
  • Less specialized features for extension-specific workflows
  • May have a steeper learning curve for extension developers

Code Comparison

Chrome Extension Tools:

import { crx } from '@crxjs/vite-plugin'
import manifest from './manifest.json'

export default {
  plugins: [crx({ manifest })]
}

Vite:

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
  plugins: [vue()]
})

Summary

Chrome Extension Tools is specifically designed for Chrome extension development, offering a more streamlined experience for this use case. It provides out-of-the-box support for extension-specific features and workflows.

Vite, on the other hand, is a more general-purpose build tool with broader applications. It offers faster build times and a larger ecosystem but requires additional setup for Chrome extension development.

The choice between the two depends on the project's specific needs and the developer's familiarity with each tool. Chrome Extension Tools may be more suitable for dedicated extension projects, while Vite might be preferred for its versatility and performance in various web development scenarios.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

CRXJS

CRXJS

Build cross-browser extensions with native HMR and zero-config setup

NPM version

📚 Documentation | 💬 Discord

📦 Create CRXJS Project

npm create crxjs@latest

[!IMPORTANT] @latest MUST NOT be omitted, otherwise npm may resolve to a cached and outdated version of the package.

✨ Features

  • 🧩 Full Vite Plugin Ecosystem - Leverage any Vite-compatible plugins with zero extra setup
  • ⚙️ Zero Configuration - Start developing immediately with intelligent defaults
  • 3️⃣ Manifest V3 Support - Built for modern Chrome extensions with enhanced security
  • 🔥 True Hot Module Replacement - Instant UI updates while preserving extension state 🎈works with content scripts
  • 📁 Static Asset Import - Directly reference images/fonts in your code
  • 🤖 Auto Web-Accessible Resources - Automatic generation of web_accessible_resources manifest entries

[!NOTE]
Looking for MV2 support? See rollup-plugin

💻 Development

  • Clone this repository
  • Install pnpm
  • Install dependencies using pnpm install
  • Build the vite-plugin project using pnpm build:vite-plugin
  • Playgrounds project is located at playgrounds/**, using pnpm play can run the playgrounds
  • Cd into the vite-plugin directory using cd packages/vite-plugin
  • Test using pnpm run test
  • Use DeepWiki to learn more about CRXJS

💝 Contributors

This project exists thanks to all the people who contribute.

And thank you to all our backers! 🙏

🤝 Supporting

If these plugins have helped you ship your product faster, please consider sponsoring me on GitHub.

NPM DownloadsLast 30 Days