Connect+Documentation
ExtensionsAPI reference

connect.windows

The single-window surface — read window state, open URLs, and change focus/state.

The shell is single-window, so this is an honest, thin surface — enough for Chrome-shaped code to work, without pretending Connect+ is multi-window. Read with tabs.read; change with tabs.write.

  • Capabilities: tabs.read (read), tabs.write (change)
  • Namespace: connect.windows

Walkthrough

Read the window and its tabs.

  1. Declare tabs.read (and tabs.write if you'll change window state).
  2. Read the window, populating its tabs:
    const win = await connect.windows.getCurrent({ populate: true });
  3. Change focus/state with update when needed.

Methods

windows.get(options?) · getCurrent · getLastFocused · getAll

Read the window (they all resolve the same single window).

How to use it

  1. Call any of them — they're interchangeable here.
  2. Pass { populate: true } to include the window's tabs.

Signatureconnect.windows.get(options?) (and getCurrent, getLastFocused, getAll) · Capability: tabs.read

Parameters

ParameterTypeRequiredDescription
options.populatebooleannoInclude the window's tabs in the result.

ReturnsPromise<Window> (or Window[] for getAll).

const win = await connect.windows.getCurrent({ populate: true });
console.log(win.tabs.length);

windows.create(options)

Open URL(s) as tab(s).

How to use it

  1. Pass url (a string or array) to open as tab(s).
  2. Set focused: true to bring the app forward.

Signatureconnect.windows.create({ url?, focused? }) · Capability: tabs.write

Parameters

ParameterTypeRequiredDescription
urlstring | string[]noThe URL(s) to open as tab(s).
focusedbooleannoFocus the app after opening.

ReturnsPromise<Window>.

windows.update(options)

Change window state.

How to use it

  1. Pass the fields you want to change (focused, state, drawAttention).
  2. Note bounds are read-only — the shell owns geometry.

Signatureconnect.windows.update({ focused?, state?, drawAttention? }) · Capability: tabs.write

Parameters

ParameterTypeRequiredDescription
focusedbooleannoFocus / blur the app.
state'normal' | 'minimized' | 'maximized'noWindow state.
drawAttentionbooleannoFlash for attention.

ReturnsPromise<Window>. Bounds are read-only.

Events

Each needs tabs.read and returns an unsubscribe function.

windows.onFocusChanged(cb)

App focus / blur.

How to use it

  1. Subscribe to pause/resume work when the app loses/gains focus.
  2. A payload of -1 means the app lost focus.

Payload — the window id, or -1 when the app loses focus.

windows.onCreated(cb) · windows.onRemoved(cb)

Window lifecycle.

How to use it

  1. Subscribe for parity with Chrome-shaped code; here it's the single window.

Payload — the window id.

Notes

  • Because there's exactly one window, get/getCurrent/getLastFocused are interchangeable — the variants exist for Chrome-code parity.

On this page