Description
Use the chrome.sessions API to query and restore tabs and windows from a browsing session.
Permissions
sessionsTypes
Device
Properties
- 
    deviceNamestring The name of the foreign device. 
- 
    sessionsSession[] A list of open window sessions for the foreign device, sorted from most recently to least recently modified session. 
Filter
Properties
- 
    maxResultsnumber optional The maximum number of entries to be fetched in the requested list. Omit this parameter to fetch the maximum number of entries ( sessions.MAX_SESSION_RESULTS).
Session
Properties
- 
    lastModifiednumber The time when the window or tab was closed or modified, represented in seconds since the epoch. 
- 
    tabTab optional The tabs.Tab, if this entry describes a tab. Either this orsessions.Session.windowwill be set.
- 
    windowWindow optional The windows.Window, if this entry describes a window. Either this orsessions.Session.tabwill be set.
Properties
MAX_SESSION_RESULTS
The maximum number of sessions.Session that will be included in a requested list.
Value
25 
 
Methods
getDevices()
chrome.sessions.getDevices(
filter?: Filter,
): Promise<Device[]>
Retrieves all devices with synced sessions.
Parameters
- 
    filterFilter optional 
Returns
- 
            Promise<Device[]> Chrome 96+
getRecentlyClosed()
chrome.sessions.getRecentlyClosed(
filter?: Filter,
): Promise<Session[]>
Gets the list of recently closed tabs and/or windows.
Parameters
- 
    filterFilter optional 
Returns
- 
            Promise<Session[]> Chrome 96+
restore()
chrome.sessions.restore(
sessionId?: string,
): Promise<Session>
Reopens a windows.Window or tabs.Tab, with an optional callback to run when the entry has been restored.
Parameters
- 
    sessionIdstring optional The windows.Window.sessionId, ortabs.Tab.sessionIdto restore. If this parameter is not specified, the most recently closed session is restored.
Returns
- 
            Promise<Session> Chrome 96+
Events
onChanged
chrome.sessions.onChanged.addListener(
callback: function,
)
Fired when recently closed tabs and/or windows are changed. This event does not monitor synced sessions changes.
Parameters
- 
    callbackfunction The callbackparameter looks like:() => void