Full Stack & AI Engineer Guide: Chrome Extensions (Manifest V3) & Side Panel AI Copilots

Enterprise workflow copilots—for CRM enrichment, clinical EHR charting, legal contract review, and developer productivity—often live right alongside the user's active browser tab as a Chrome Extension (Manifest V3) Side Panel. However, Manifest V3 replaces persistent background pages with ephemeral Service Workers that terminate after 30 seconds of inactivity, breaking naive WebSocket connections and in-memory state variables. As a Senior Full Stack Engineer and AI Application Engineer, here is how I build Web Store-compliant Manifest V3 extensions in React and TypeScript.

1. Ephemeral Service Worker State & Typed Message Passing

In Manifest V3, background Service Workers must register all event listeners (`chrome.runtime.onMessage`, `chrome.alarms.onAlarm`) synchronously at the top level of the script and persist session state in `chrome.storage.session` or `chrome.storage.local` rather than global JS variables:

// src/background/service-worker.ts
export interface AnalyzePageContextMessage {
  type: "ANALYZE_ACTIVE_TAB_CONTEXT";
  selectionText: string;
  pageUrl: string;
}

chrome.sidePanel
  .setPanelBehavior({ openPanelOnActionClick: true })
  .catch((err) => console.error("SidePanel init error:", err));

chrome.runtime.onMessage.addListener(
  (message: AnalyzePageContextMessage, _sender, sendResponse) => {
    if (message.type !== "ANALYZE_ACTIVE_TAB_CONTEXT") {
      return false;
    }
    handleStreamingAnalysis(message)
      .then((summary) => sendResponse({ ok: true, summary }))
      .catch((err) => sendResponse({ ok: false, error: String(err) }));
    // Return true to keep the message channel open for async sendResponse
    return true;
  }
);

async function handleStreamingAnalysis(msg: AnalyzePageContextMessage): Promise {
  const { authToken } = await chrome.storage.session.get("authToken");
  const resp = await fetch("https://api.example-copilot.com/v1/analyze", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      Authorization: `Bearer ${authToken ?? ""}`,
    },
    body: JSON.stringify({ url: msg.pageUrl, snippet: msg.selectionText }),
  });
  const data = await resp.json();
  return data.summary;
}

2. Least-Privilege Permissions (`activeTab`) for Fast Chrome Web Store Approval

Requesting broad `` host permissions when `activeTab` and `scripting` suffice triggers lengthy manual Chrome Web Store security reviews. Scoping permissions strictly to user-invoked actions guarantees both user privacy and rapid store approval.

3. Hire a Senior Full Stack & AI Chrome Extension Engineer

Building a Side Panel AI assistant, CRM browser overlay, or Manifest V3 migration? Explore my Full Stack Engineer Pillar Guide, review my AI Application Engineer Pillar Guide, or book a 1-Day Chrome Extension Architecture Sprint.


About the Author — Hire Aldian Fazrihady (Cloud Engineer, GCP Professional Cloud Architect, GCP Professional Data Engineer, Backend, AI & Full Stack Engineer)

Aldian Fazrihady is a Top-Rated Senior Cloud Engineer, GCP Professional Cloud Architect (Google Cloud Certified), GCP Professional Data Engineer (Google Cloud Certified), Backend Engineer (Python, Django, FastAPI, Go, PostgreSQL), AI Application Engineer (LLMs, RAG, MCP, Google ADK, LangGraph), and Full Stack Engineer (React, Next.js, TypeScript) with 15+ years of production software engineering experience.

Hire Aldian Fazrihady on Upwork | Book 1-Day Programming Service ($100 USD / Rp 1.000.000) | View Live AI Portfolio | Send a Direct Message

Related Engineering Articles

Engineering Role Pillar Guides & Category Hubs