Welcome What's new in Chrome extensions API reference Samples
Welcome What's new in Chrome extensions API reference Samples

chrome.sessions

  • Description

    Use the chrome.sessions API to query and restore tabs and windows from a browsing session.

  • Permissions
    sessions

Summary

Types

Device

Properties

  • deviceName

    string

    The name of the foreign device.

  • sessions

    A list of open window sessions for the foreign device, sorted from most recently to least recently modified session.

Filter

Properties

  • maxResults

    number 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

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,
  callback?: function,
)
Promise

Retrieves all devices with synced sessions.

Parameters

  • filter

    Filter optional

  • callback

    function optional

    The callback parameter looks like: (devices: Device[]) => void

Returns

  • Promise<Device[]>

    Chrome 96+

    Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.

getRecentlyClosed

chrome.sessions.getRecentlyClosed(
  filter?: Filter,
  callback?: function,
)
Promise

Gets the list of recently closed tabs and/or windows.

Parameters

  • filter

    Filter optional

  • callback

    function optional

    The callback parameter looks like: (sessions: Session[]) => void

    • sessions

      The list of closed entries in reverse order that they were closed (the most recently closed tab or window will be at index 0). The entries may contain either tabs or windows.

Returns

  • Promise<Session[]>

    Chrome 96+

    Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.

restore

chrome.sessions.restore(
  sessionId?: string,
  callback?: function,
)
Promise

Reopens a windows.Window or tabs.Tab, with an optional callback to run when the entry has been restored.

Parameters

Returns

  • Promise<Session>

    Chrome 96+

    Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.

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

  • callback

    function

    The callback parameter looks like: () => void

This site uses cookies to deliver and enhance the quality of its services and to analyze traffic. If you agree, cookies are also used to serve advertising and to personalize the content and advertisements that you see. Learn more about our use of cookies.