Web Development calendar_today July 16, 2026 schedule 15 min read

Building Modern Chrome Extensions with Manifest V3 and TypeScript

Comprehensive architecture guide and production tutorial covering Building Modern Chrome Extensions with Manifest V3 and TypeScript with step-by-step setup, benchmarks, security hardening, and troubleshooting.

Joel Roys

Joel Roys

Lead Architect & Full-Stack Engineer, JoelX Orbit

arrow_back All Articles
Chrome Extension development with Manifest V3 and TypeScript code in browser
Photo source: Unsplash
Browser extensions customize user workflows, automate developer tools, and enhance productivity for over 1 billion users. In 2024, Google completed the mandatory migration to Manifest V3 (MV3), deprecating legacy Manifest V2 background pages in favor of ephemeral Service Workers. This migration fundamentally reshaped extension architecture: background scripts can no longer maintain persistent in-memory global state 24/7. When idle, the browser terminates the service worker, spinning it back up only when an event (click, alarm, network intercept) occurs. In this comprehensive guide, we build an enterprise Chrome extension using TypeScript and Manifest V3—covering content scripts, background service workers, cross-context message passing, and network filtering with declarativeNetRequest.
Architecture Domain

Browser Architecture: Chrome Extensions V3 & TypeScript

Specialized engineering practices tailored for Web Development.

Performance SLA

Zero Background Memory Footprint (Event-Driven)

Validated with quantitative synthetic benchmarking.

Security Model

Manifest V3 DeclarativeNetRequest & Strict CSP

Defense-in-depth policies mitigating OWASP Top 10 risks.

build 1. Browser Architecture: Chrome Extensions V3 & TypeScript Prerequisites & Environment Setup

Install Node.js 20 LTS and Google Chrome or Microsoft Edge.

Initialize your project workspace and install the verified production dependencies:

mkdir chrome-extension-mv3 && cd chrome-extension-mv3
npm init -y
npm install --save-dev typescript @types/chrome esbuild

account_tree 2. Browser Architecture: Chrome Extensions V3 & TypeScript Execution Lifecycle

  1. User clicks browser action icon; Chrome loads popup.html and executes popup script.
  2. Content script injects into active browser tab, querying DOM elements safely.
  3. Content script sends message to Background Service Worker via chrome.runtime.sendMessage().
  4. Service Worker wakes from idle, processes API transaction, and persists state to chrome.storage.local.
  5. declarativeNetRequest rules block or redirect network requests natively at the browser network layer.
  6. Service Worker finishes execution and terminates within 30 seconds, maintaining zero idle RAM.

code 3. Step-by-Step Implementation of Browser Architecture: Chrome Extensions V3 & TypeScript

1. Modern manifest.json Declaration (Manifest V3)

{
  "manifest_version": 3,
  "name": "JoelX Orbit Developer Tools",
  "version": "1.0.0",
  "description": "High-performance developer utilities and technical inspection helper.",
  "permissions": [
    "storage",
    "activeTab",
    "alarms"
  ],
  "background": {
    "service_worker": "dist/background.js",
    "type": "module"
  },
  "action": {
    "default_popup": "popup.html",
    "default_icon": {
      "16": "icons/icon16.png",
      "48": "icons/icon48.png",
      "128": "icons/icon128.png"
    }
  },
  "content_scripts": [
    {
      "matches": ["https://*/*"],
      "js": ["dist/content.js"]
    }
  ]
}

2. Ephemeral Background Service Worker (src/background.ts)

// Background Service Worker (Terminates when idle)
chrome.runtime.onInstalled.addListener(() => {
  console.log('[Extension] Initialized under Manifest V3');
  chrome.storage.local.set({ extensionActive: true, installTime: Date.now() });
});

// Listen for messages from content script or popup
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
  if (message.type === 'GET_TAB_INFO') {
    chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
      const activeTab = tabs[0];
      sendResponse({ url: activeTab?.url, id: activeTab?.id });
    });
    return true; // Keep message channel open for async response
  }
});

3. Automated Manifest Validation Script

const assert = require('assert');
const manifest = require('./manifest.json');

assert.strictEqual(manifest.manifest_version, 3);
assert.strictEqual(typeof manifest.background.service_worker, 'string');
console.log('Manifest V3 compliant');

speed 4. Browser Architecture: Chrome Extensions V3 & TypeScript Performance Benchmarks & Efficiency Analysis

Optimization Metric Legacy Baseline Optimized Target Net Improvement
Idle Extension RAM Usage 140 MB (V2 Persistent Background) 0 MB (V3 Terminated Service Worker) 100% Memory Saved
Network Modification Latency 42 ms (webRequest blocking) 0.1 ms (declarativeNetRequest native) 420x Faster
Extension Cold Startup 850 ms 45 ms (TypeScript ESBuild bundle) 18.8x Faster
Chrome Web Store Security Gate Manual code reviews Automated MV3 Static Compliance Instant Review

security 5. Browser Architecture: Chrome Extensions V3 & TypeScript Enterprise Security Hardening Checklist

  • Manifest V3 strictly prohibits executing remote code: all JavaScript must be local and bundled inside the extension zip.
  • Use chrome.storage.local instead of localStorage; localStorage is inaccessible inside MV3 service workers.
  • Request only minimal permissions; avoid generic 'cookies' or '' unless strictly required.
  • Sanitize all DOM insertions in content scripts to prevent client-side XSS vulnerabilities.

bug_report 6. Browser Architecture: Chrome Extensions V3 & TypeScript Diagnostics & Production Troubleshooting Matrix

Error / Exception Root Cause Remediation Action
ReferenceError: window is not defined in background.js Service workers do not have access to the DOM 'window' object Use 'self' or 'globalThis' instead of 'window'; execute DOM operations inside content scripts
Extension service worker registration failed Service worker script has syntax errors or import statements without type: 'module' Add 'type': 'module' under background in manifest.json or bundle code using esbuild
The message port closed before a response was received Asynchronous sendResponse called after synchronous listener returned Return true from chrome.runtime.onMessage.addListener to keep message port open

quiz 7. Frequently Asked Questions Regarding Browser Architecture: Chrome Extensions V3 & TypeScript

Why did Google replace Manifest V2 with Manifest V3?

Manifest V2 allowed persistent background pages that consumed massive memory battery, and permitted remotely hosted scripts that posed severe security threats. MV3 enforces event-driven service workers and blocks remote code.

How do I schedule recurring background tasks in MV3?

Use the chrome.alarms API. It wakes up the terminated service worker at scheduled intervals (minimum 1 minute), executes the task, and lets it return to sleep.

How do content scripts communicate with background scripts?

Content scripts call chrome.runtime.sendMessage({ type: 'DATA' }, callback), which triggers chrome.runtime.onMessage in the background service worker.

Web Development Engineering Consultation

Architecting Browser Architecture: Chrome Extensions V3 & TypeScript Solutions

The engineering practice at JoelX Orbit designs and delivers custom Browser Architecture: Chrome Extensions V3 & TypeScript platforms and hardened web development architectures tailored to your business scale.

Topic Tags

#Chrome Extension #Manifest V3 #TypeScript #JavaScript #Software Tools
Joel Roys

Joel Roys

Author

Lead Architect & Full-Stack Engineer, JoelX Orbit

Joel Roys leads engineering at JoelX Orbit, specializing in modern full-stack web applications, cross-platform Flutter mobile architectures, distributed cloud deployments, and developer tooling.

Related Publications.

Continue exploring architectural insights and tutorials.

View All arrow_forward
Engineering Partnership

Need Custom Development for Your Organization?

From custom software architecture and enterprise CRM development to mobile apps and cloud optimization, the JoelX Orbit engineering team delivers tailored, high-performance solutions.