Top Related Projects
Scaffold out a Chrome extension
A Chrome Extensions boilerplate using React 18 and Webpack 5.
🖥🔋Web Extension starter to build "Write Once Run on Any Browser" extension
Chrome Extension TypeScript Starter
Chrome Extensions Samples
Quick Overview
Chrome Extension CLI is a command-line tool designed to streamline the process of creating and developing Chrome extensions. It provides a modern development setup with features like Hot Module Replacement (HMR) and automatic reloading, making it easier for developers to build and test Chrome extensions.
Pros
- Offers a quick and easy setup for Chrome extension projects
- Includes Hot Module Replacement (HMR) for faster development
- Provides automatic reloading of extension pages
- Supports modern JavaScript features and TypeScript
Cons
- Limited customization options for advanced users
- May have a learning curve for developers new to CLI tools
- Documentation could be more comprehensive
- Might not support all edge cases or complex extension scenarios
Getting Started
To get started with Chrome Extension CLI, follow these steps:
# Install Chrome Extension CLI globally
npm install -g chrome-extension-cli
# Create a new Chrome extension project
chrome-extension-cli create my-extension
# Navigate to the project directory
cd my-extension
# Start the development server
npm start
# Build the extension for production
npm run build
After running these commands, you'll have a basic Chrome extension project set up with a development environment. You can then load the extension in Chrome by navigating to chrome://extensions/
, enabling "Developer mode", and clicking "Load unpacked" to select your extension's directory.
Competitor Comparisons
Scaffold out a Chrome extension
Pros of generator-chrome-extension
- Uses Yeoman for scaffolding, providing a more robust and flexible project generation system
- Offers more customization options during project setup
- Includes support for ES6 and TypeScript out of the box
Cons of generator-chrome-extension
- Less actively maintained, with fewer recent updates
- More complex setup process due to Yeoman dependency
- May have a steeper learning curve for beginners
Code Comparison
generator-chrome-extension:
'use strict';
const Generator = require('yeoman-generator');
const chalk = require('chalk');
const yosay = require('yosay');
module.exports = class extends Generator {
// ...
};
chrome-extension-cli:
#!/usr/bin/env node
const program = require('commander');
const chalk = require('chalk');
const createExtension = require('./createExtension');
program
.version(require('../package').version)
// ...
The code snippets show that generator-chrome-extension uses Yeoman's generator system, while chrome-extension-cli uses a more straightforward CLI approach with Commander.js. This reflects the different philosophies and complexities of the two projects.
generator-chrome-extension offers more flexibility and power through Yeoman, but chrome-extension-cli provides a simpler, more focused tool for quickly creating Chrome extensions. The choice between them depends on the user's needs and familiarity with the respective ecosystems.
A Chrome Extensions boilerplate using React 18 and Webpack 5.
Pros of chrome-extension-boilerplate-react
- Built-in React support, allowing for more complex and dynamic UI development
- Hot reloading feature for faster development and testing
- Includes example components and a more structured project layout
Cons of chrome-extension-boilerplate-react
- More complex setup and larger initial codebase
- Potentially steeper learning curve for developers new to React
- May include unnecessary features for simpler extensions
Code Comparison
chrome-extension-boilerplate-react:
import React from 'react';
import { render } from 'react-dom';
import Popup from './Popup';
import './index.css';
render(<Popup />, document.getElementById('root'));
chrome-extension-cli:
document.addEventListener('DOMContentLoaded', function() {
var checkPageButton = document.getElementById('checkPage');
checkPageButton.addEventListener('click', function() {
chrome.tabs.getSelected(null, function(tab) {
alert("Hello from your Chrome extension!");
});
}, false);
}, false);
The chrome-extension-boilerplate-react uses React components and JSX, while chrome-extension-cli uses vanilla JavaScript for DOM manipulation. The React-based approach offers more scalability and maintainability for complex UIs, while the vanilla JS approach is simpler and more lightweight for basic extensions.
🖥🔋Web Extension starter to build "Write Once Run on Any Browser" extension
Pros of web-extension-starter
- Cross-browser compatibility: Supports Chrome, Firefox, and Opera
- TypeScript support: Provides type safety and better developer experience
- More comprehensive boilerplate: Includes popup, options, and content scripts
Cons of web-extension-starter
- Steeper learning curve: More complex setup and configuration
- Heavier project structure: May be overkill for simple extensions
Code Comparison
web-extension-starter (webpack.config.js):
module.exports = {
entry: {
popup: path.join(__dirname, 'source/Popup/index.tsx'),
options: path.join(__dirname, 'source/Options/index.tsx'),
background: path.join(__dirname, 'source/Background/index.ts'),
contentScript: path.join(__dirname, 'source/ContentScript/index.ts'),
},
// ...
};
chrome-extension-cli (webpack.config.js):
module.exports = {
entry: {
popup: './src/popup.js',
background: './src/background.js',
},
// ...
};
The web-extension-starter configuration is more comprehensive, including additional entry points for options and content scripts, while chrome-extension-cli provides a simpler setup with just popup and background scripts.
Chrome Extension TypeScript Starter
Pros of chrome-extension-typescript-starter
- Built-in TypeScript support, providing better type safety and developer experience
- Includes a sample project structure with TypeScript configuration
- Uses Webpack for bundling, offering more advanced build options
Cons of chrome-extension-typescript-starter
- Less opinionated about project structure compared to chrome-extension-cli
- Requires more manual setup and configuration for additional features
- May have a steeper learning curve for developers new to TypeScript
Code Comparison
chrome-extension-typescript-starter (tsconfig.json):
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
"esModuleInterop": true
}
}
chrome-extension-cli (package.json):
{
"scripts": {
"start": "webextension-toolbox dev",
"build": "webextension-toolbox build"
}
}
The chrome-extension-typescript-starter provides a TypeScript configuration file, enabling type checking and compilation. In contrast, chrome-extension-cli focuses on simplifying the development process with predefined scripts for development and building, using the webextension-toolbox.
Both repositories aim to streamline Chrome extension development, but they cater to different preferences and skill levels. chrome-extension-typescript-starter is more suitable for developers who prefer TypeScript and want more control over their build process, while chrome-extension-cli offers a simpler setup with less configuration required.
Chrome Extensions Samples
Pros of chrome-extensions-samples
- Comprehensive collection of examples covering various extension features
- Official Google repository, ensuring up-to-date and best practice implementations
- Includes samples for both Manifest V2 and V3, catering to different extension versions
Cons of chrome-extensions-samples
- Lacks a CLI tool for quick project setup and scaffolding
- May be overwhelming for beginners due to the large number of examples
- Doesn't provide a streamlined development workflow or build process
Code Comparison
chrome-extensions-samples (basic extension structure):
{
"manifest_version": 3,
"name": "My Extension",
"version": "1.0",
"description": "A sample extension",
"action": {
"default_popup": "popup.html"
}
}
chrome-extension-cli (generated project structure):
my-extension/
├── src/
│ ├── background.js
│ ├── content.js
│ └── popup/
│ ├── index.html
│ └── index.js
├── public/
│ └── manifest.json
└── package.json
chrome-extension-cli provides a more organized project structure with separate directories for source files and public assets, while chrome-extensions-samples focuses on individual example implementations without a standardized project structure.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Chrome Extension CLI
The CLI for your next Chrome Extension. ð
Quick Overview
npm install -g chrome-extension-cli
chrome-extension-cli my-extension
cd my-extension
npm run watch
Then follow these instructions to see your extension:
- Open chrome://extensions
- Check the Developer mode checkbox
- Click on the Load unpacked extension button
- Select the folder my-extension/build
When you're ready to publish to Chrome Web Store, create a minified bundle with npm run build
and zip it with npm run pack
.
Or you can zip the build
folder manually.


Get Started Immediately
You donât need to install or configure Webpack.
Webpack comes in preconfigured, so that you can focus on the code.
Just create a project, and youâre good to go.
Creating an Extension
Installation
npm install -g chrome-extension-cli
Usage
chrome-extension-cli <project-name>
Example:
chrome-extension-cli my-extension
It will create a directory called my-extension
inside the current folder.
Inside that directory, it will generate the initial project structure and install the transitive dependencies:
my-extension
âââ README.md
âââ node_modules
âââ package.json
âââ .gitignore
âââ config // Webpack with minimal configurations
â âââ paths.js
â âââ webpack.common.js
â âââ webpack.config.js
âââ public
â âââ icons
â â âââ icon_16.png
â â âââ icon_32.png
â â âââ icon_48.png
â â âââ icon_128.png
â âââ *.html // HTML files will vary depending on extension type
â âââ manifest.json
âââ src
âââ *.css // CSS files will vary depending on extension type
âââ *.js // JS files will vary depending on extension type
Once the installation is done, you can open your project folder:
cd my-extension
Inside the newly created project, you can run some built-in commands:
npm run watch
Runs the app in development mode.
Then follow these instructions to see your app:
- Open chrome://extensions
- Check the Developer mode checkbox
- Click on the Load unpacked extension button
- Select the folder my-extension/build
npm run build
Builds the app for production to the build folder.
Run npm run pack
to
zip the build folder and your app is ready to be published on Chrome Web Store.
Or you can zip it manually.
npm run pack
Packs the build folder into a zip file under release folder.
npm run repack
Rebuilds and packs the app into a zip file.
It is a shorthand for npm run build && npm run pack
.
npm run format
Formats all the HTML, CSS, JavaScript, TypeScript and JSON files.
What's included?
Your environment will have everything you need to build a Chrome Extension:
- ES6 syntax support.
- A watch script to listen file changes and build automatically.
- A build script to bundle JS, CSS, and images for production.
Extension types
With Chrome Extension CLI you can built any of the below extensions:
Popup
Add features to Active Tab.

Override page
Override default page like New Tab, Bookmarks, or History page.

DevTools
Add features to Chrome Developer Tools.

Side Panel
Add features to Chrome Side Panel.

More information about templates.
CLI options
chrome-extension-cli my-extension --override-page
Creates an extension that overrides default New Tab page.
You can also pass other values to --override-page
option to override other default pages like Bookmarks and History page.
chrome-extension-cli my-extension --override-page // Override New Tab page
chrome-extension-cli my-extension --override-page=bookmarks // Override Bookmarks page
chrome-extension-cli my-extension --override-page=history // Override History page
chrome-extension-cli my-extension --devtools
Creates a Panel inside developer tools.
chrome-extension-cli my-extension --side-panel
Creates a Panel in the browser's side panel alongside the main content of a webpage.
chrome-extension-cli my-extension --language
Creates an extension for supported languages like JavaScript and TypeScript.
By default extension is created for JavaScript language and you can also pass other value to --language
option to create extension for TypeScript.
chrome-extension-cli my-extension // Language JavaScript (default)
chrome-extension-cli my-extension --language=javascript // Language JavaScript
chrome-extension-cli my-extension --language=typescript // Language TypeScript
Contributing
See the contribution guide and join the contributors!
FAQs
See the FAQs.
License
Chrome Extension CLI is open source software licensed as MIT.
Many thanks to create-react-app for the inspiration with this readme file.
Jupiter Icon used in templates made by Freepik from www.flaticon.com.
Top Related Projects
Scaffold out a Chrome extension
A Chrome Extensions boilerplate using React 18 and Webpack 5.
🖥🔋Web Extension starter to build "Write Once Run on Any Browser" extension
Chrome Extension TypeScript Starter
Chrome Extensions Samples
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot