Create Command

The create command is responsible for setting up a new browser extension project using Extension.js. This command accepts flags like --template for initializing your extension with various templates, and allows you to define the directory or path where the extension will be created. The command is designed to simplify the setup process for developers, providing a streamlined way to get started with cross-browser extension development.

How Does It Work?

Create Command

Given a folder or template URL, the create command initializes a new extension project in the specified directory applying the chosen template and relevant metadata to the project.

Usage

You can run the create command using the following syntax. Replace <extension-name|extension-path> with your project name or path and set any required options:

Demo Video

npm
pnpm
yarn
npx extension@latest create <extension-name|extension-path> [options]

Example Usage with Templates

Demo Video

npm
pnpm
yarn
npx extension@latest create my-extension --template=react

This example demonstrates creating a new extension using the react template. You can substitute react with any available template from the Templates section.

Path Option

The create command can also accept a specific directory where you want to create the extension. If no path is provided, it defaults to the current working directory.

npm
pnpm
yarn
extension create path/to/my-extension --template=react

In this example, the extension is created in the path/to/my-extension directory.

Arguments and Flags

The create command accepts several arguments and flags to customize the behavior of the extension creation:

Flag Argument What it does Defaults to
[path or name] The extension path or name If a path is defined, loads the local extension. If a name is provided, loads the extension in the current working directory. process.cwd()
-t, --template Name of the template used to bootstrap your extension Bootstrap your extension using a template new
--install Whether or not to auto install the template dependencies Install dependencies and devDependencies during creation time true
  • Path or Name: If a path is provided, the extension is created at that location. If a name is provided, it is created in the current working directory.
  • --template: Specifies the template to use when bootstrapping the extension (e.g., react, typescript).

Example Commands

This command creates a new extension named my-new-extension using the React template.

npm
pnpm
yarn
npx extension@latest create my-extension --template=react

Available Templates

Prototype screenshot

init

An Extension.js template

manifest.json
Prototype screenshot

action

An Extension.js template

action
Prototype screenshot

content

An Extension.js template

content
Prototype screenshot

content-esm

An Extension.js template

content
Prototype screenshot

content-css-modules

An Extension.js template

content
Prototype screenshot

content-less

An Extension.js template

content
Prototype screenshot

content-less-modules

An Extension.js template

content
Prototype screenshot

content-main-world

An Extension.js template

content
Prototype screenshot

content-sass

An Extension.js template

content
Prototype screenshot

content-sass-modules

An Extension.js template

content
Prototype screenshot

declarative_net_request

An Extension.js template

manifest.json
Prototype screenshot

action-locales

An Extension.js template

action
Prototype screenshot

new

An Extension.js template

newTab
Prototype screenshot

new-esm

An Extension.js template

newTab
Prototype screenshot

new-less

An Extension.js template

newTab
Prototype screenshot

new-sass

An Extension.js template

newTab
Prototype screenshot

sidebar

An Extension.js template

sidebar
Prototype screenshot

special-folders-pages

An Extension.js template

manifest.json
Prototype screenshot

special-folders-scripts

An Extension.js template

manifest.json
Prototype screenshot

storage

An Extension.js template

manifest.json
Prototype screenshot

content-typescript

An Extension.js template

content
Prototype screenshot

content-env

An Extension.js template

content
Prototype screenshot

new-typescript

An Extension.js template

newTab
Prototype screenshot

new-env

An Extension.js template

newTab
Prototype screenshot

action-chatgpt

An Extension.js template

action
Prototype screenshot

new-crypto

An Extension.js template

newTab
Prototype screenshot

new-node-apis

An Extension.js template

newTab
Prototype screenshot

content-react-svgr

An Extension.js template

content
Prototype screenshot

new-react-router

An Extension.js template

newTab
Prototype screenshot

new-react

An Extension.js template

newTab
Prototype screenshot

content-react

An Extension.js template

content
Prototype screenshot

new-preact

An Extension.js template

newTab
Prototype screenshot

content-preact

An Extension.js template

content
Prototype screenshot

content-extension-config

An Extension.js template

content
Prototype screenshot

new-vue

An Extension.js template

newTab
Prototype screenshot

content-vue

An Extension.js template

content
Prototype screenshot

new-svelte

An Extension.js template

newTab
Prototype screenshot

new-config-eslint

An Extension.js template

newTab
Prototype screenshot

new-config-lint

An Extension.js template

newTab
Prototype screenshot

new-config-prettier

An Extension.js template

newTab
Prototype screenshot

new-config-stylelint

An Extension.js template

newTab
Prototype screenshot

content-tailwind

An Extension.js template

content
Prototype screenshot

new-tailwind

An Extension.js template

newTab
npx extension dev --browser=init

Best Practices

  • Starting from a Template: Using a template is the fastest way to get started with browser extension development in Extension.js.

Next Steps