Web Ext React Template

screenshot of Web Ext React Template
react

Template for a browser extension with React + TypeScript + esbuild

Overview:

This article provides a guide on how to build a browser extension using React, TypeScript, and esbuild. It supports both Firefox and Chrome browsers. The article covers the basic usage, installation instructions, and customization options for the browser extension.

Features:

  • Build a browser extension with React + TypeScript + esbuild.
  • Supports both Firefox and Chrome browsers.
  • Provides basic usage examples and instructions.
  • Allows customization options for add-on ID and other settings.

Build for Firefox:

  1. Enable watch mode: yarn watch
  2. Enable source map: yarn build --sourcemap

Build for Chrome:

  1. Build for both browsers: yarn build

Run with browsers:

Firefox:

  • Load the "web-ext" tool: yarn global add web-ext
  • Run the extension in Firefox: web-ext run --browser firefox

Chrome:

  • Load the extension in Chrome:
    • Open Chrome and type chrome://extensions in the address bar.
    • Enable "Developer mode" using the toggle switch.
    • Click on "Load unpacked" and select the extension folder.

Create a package for Firefox (zip):

To install an unsigned add-on, follow these steps:

  1. Use Firefox Developer Edition.
  2. Change the settings to allow unsigned add-ons.

Type check:

  • Run type checking using ESLint: yarn lint

Fix Prettier:

  • Fix code formatting using Prettier: yarn format

Customization:

To change the add-on ID for Firefox, follow these steps:

  1. Edit firefox.json.
  2. Update the ID to match the required format: {<UUID>}<alphanum>@<alphanum>

Summary:

This article provides a comprehensive guide on building a browser extension using React, TypeScript, and esbuild. It covers the basic usage, installation, and customization options for both Firefox and Chrome browsers. The provided code snippets and instructions make it easy to follow along and build a browser extension with the desired features.

react
React

React is a widely used JavaScript library for building user interfaces and single-page applications. It follows a component-based architecture and uses a virtual DOM to efficiently update and render UI components

template
Templates & Themes

A template or theme refers to a pre-designed layout or structure that provides a basic framework for building a specific type of application or website. It typically includes good design, placeholder content and functional features, allowing developers to customize and fill in the details according to their specific needs.

eslint
Eslint

ESLint is a linter for JavaScript that analyzes code to detect and report on potential problems and errors, as well as enforce consistent code style and best practices, helping developers to write cleaner, more maintainable code.

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.