create-chrome-ext-ts
v1.1.3
Published
A CLI tool to generate Chrome extension projects with TypeScript and Manifest V3
Maintainers
Readme
Chrome Extension TypeScript Template
A modern CLI tool to generate Chrome extension projects with TypeScript, using Manifest V3.
Quick Start
Generate a new Chrome extension project using npx:
npx create-chrome-ext-ts <project-name>Example:
npx create-chrome-ext-ts my-awesome-extensionCheck the version:
npx create-chrome-ext-ts -v
# or
npx create-chrome-ext-ts --versionThis will:
- Create a new directory with your project name in the current directory
- Copy all template files
- Update package.json and manifest.json with your project name
- Install npm dependencies automatically
Features
- ✅ TypeScript support
- ✅ Webpack bundling
- ✅ Manifest V3
- ✅ Background service worker
- ✅ Content script
- ✅ Popup UI
- ✅ Options page
- ✅ Chrome Storage API integration
- ✅ Message passing between components
Project Structure
.
├── src/
│ ├── background.ts # Background service worker
│ ├── content.ts # Content script (runs on web pages)
│ ├── popup.ts # Popup script
│ ├── popup.html # Popup HTML
│ ├── options.ts # Options page script
│ └── options.html # Options page HTML
├── icons/ # Extension icons (create these)
├── manifest.json # Extension manifest
├── webpack.config.js # Webpack configuration
├── tsconfig.json # TypeScript configuration
└── package.json # Dependencies
Using as a Template Repository
If you've cloned this repository, you can also use the local generate script:
npm run generate <project-name>Setup
Install dependencies:
npm installBuild the extension:
npm run buildFor development with watch mode:
npm run devLoad the extension in Chrome:
- Open Chrome and navigate to
chrome://extensions/ - Enable "Developer mode" (toggle in top right)
- Click "Load unpacked"
- Select the
distfolder
- Open Chrome and navigate to
Development
- Build:
npm run build- Creates production build indist/ - Dev:
npm run dev- Watches for changes and rebuilds automatically - Clean:
npm run clean- Removes thedistfolder - Generate:
npm run generate <name>- Creates a new project from this template
Customization
Adding New Scripts
Add entry point in
webpack.config.js:entry: { // ... existing entries newScript: "./src/newScript.ts"; }Create the TypeScript file in
src/Reference it in
manifest.jsonif needed
Modifying Permissions
Edit the permissions array in manifest.json. Common permissions:
storage- For chrome.storage APIactiveTab- Access to active tabtabs- Full tabs API accessscripting- For injecting scriptshost_permissions- For specific domains
Manifest V3 Notes
- Background scripts are now service workers (no DOM access)
- Use
chrome.storageinstead ofchrome.storage.localfor sync - Content Security Policy is stricter
- Message passing is async (use promises or callbacks)
Resources
Publishing
To publish this package to npm:
- Update the version in
package.json - Login to npm:
npm login - Publish:
npm publish
After publishing, users can generate projects with:
npx create-chrome-ext-ts <project-name>License
MIT
