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 `
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.