Transformers.js

Adds a sidebar panel that classifies the active page or your selected text with on-device AI models.

Runs on Chrome, Edge, Firefox · Manifest V3 · Surfaces: sidebar, content script, popup, background service worker · Styling: CSS · Level: intermediate

Create this project

npx extension@latest create my-transformers-js --template transformers-js
cd my-transformers-js
npm install
npm run dev

What it is for

  • Running Transformers.js models inside an extension
  • Classifying page text with no server and no API key
  • Reference for shipping on-device AI under MV3

First steps

  • Run npm run dev to launch the extension
  • Click the extension icon to open the side panel
  • Type in the text box, or use the page text or your selection, and the model classifies it on your machine

Permissions it asks for

  • sidePanel
  • storage
  • tabs
  • contextMenus
  • <all_urls>

extension.devDocumentation for extension.dev