Skip to content

shuvrojit/react-ts-browser-extension-template

Repository files navigation

React TypeScript Browser Extension

This repository contains a React application written in TypeScript for use as a browser extension. Follow the instructions below to set up, develop, and build the project.

Prerequisites

  • Node.js (v20 or above recommended)
  • npm (v9 or above recommended)
  • A modern web browser that supports installing extensions in development mode (e.g., Chrome, Firefox)

Installation

  1. Clone the repository to your local machine.
  2. Navigate into the project directory.
  3. Install the necessary dependencies:
    npm install

Scripts

In the project’s package.json, the following scripts are available:

  • dev: Starts the development server using Vite.
    npm run dev
  • build: Runs TypeScript type checking (tsc -b) and bundles the app for production using Vite.
    npm run build
  • lint: Lints the source files using ESLint.
    npm run lint
  • preview: Previews the production build locally.
    npm run preview

Development

To launch a development server and continuously rebuild on changes:

npm run dev

This will start your app at a local development URL (usually http://localhost:3000 by default), allowing you to test the browser extension’s UI.

Building the Extension

When ready to create a production build of the extension:

npm run build

This command compiles the TypeScript code, bundles it with Vite, and outputs production-ready files (typically in the dist folder). You can then load these files into your browser of choice in developer/extension mode.

Loading the Extension (Chrome Example)

  1. Open Chrome and navigate to chrome://extensions/.
  2. Enable "Developer mode" (toggle in the top right corner).
  3. Click "Load unpacked" and select the dist folder generated by the build.
  4. The extension should now appear in Chrome’s extension panel.

Additional Notes

  • If using Firefox or another browser, follow that browser’s guidelines for loading unpacked or temporary extensions.
  • Ensure your manifest.json file matches the required format for a browser extension in your target browser(s).

Contributing

Feel free to submit issues or pull requests if you find any bugs or want to suggest improvements.


Happy coding!

About

React Typescript browser extension template setup with vite

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published