connect.webNavigation
Navigation-lifecycle events across all frames — onCommitted, onCompleted, onHistoryStateUpdated.
Navigation-lifecycle events for the profile's tabs. Same consent as tab events
(tabs.read) — identical disclosure — and covering all frames.
- Capability:
tabs.read - Namespace:
connect.webNavigation
Every payload is { tabId, url, frameId, timeStamp }. frameId is 0 for the main
frame; a sub-frame uses its routing id (stable for that frame's lifetime).
Walkthrough
React to a page finishing load, top frame only.
- Declare
tabs.read(same consent as tab events):{ "capabilities": ["tabs.read"] } - Subscribe to the event you care about — usually
onCompleted. - Filter to the top frame with
if (e.frameId !== 0) return;unless you want sub-frames. - Act on
e.url/e.tabId.
connect.webNavigation.onCompleted((e) => {
if (e.frameId !== 0) return; // sub-frame — ignore
index(e.url);
});Events
Each returns an unsubscribe function and needs tabs.read.
webNavigation.onCommitted(cb)
Fires when a navigation commits (the browser has decided to load the new document).
How to use it
- Subscribe to know a navigation has started in a tab.
- Check
frameIdto tell main frame from sub-frame.
Payload — { tabId, url, frameId, timeStamp }.
webNavigation.onCompleted(cb)
Fires when the page finished loading.
How to use it
- Subscribe to run work once the page is ready (e.g. index it, inject UI).
- Filter to
frameId === 0for the top frame.
Payload — { tabId, url, frameId, timeStamp }.
webNavigation.onHistoryStateUpdated(cb)
Fires on an SPA history change — pushState / replaceState — where the document
doesn't reload.
How to use it
- Subscribe to follow route changes in single-page apps that never reload.
Payload — { tabId, url, frameId, timeStamp }.
Notes
- These mirror the tab lifecycle at the navigation level; pair them with
connect.tabsevents when you need the tab object too. - There is no
onBeforeNavigate/onErrorOccurredin v1 — commit and complete are the two anchors, plus the SPA hook.