v157 · enabled by default · web api · web bluetooth
Web Bluetooth: Make BluetoothRemoteGATTServer an EventTarget
BluetoothRemoteGATTServer — the object you get from device.gatt, representing the GATT connection to a remote Bluetooth device — now inherits from EventTarget. It therefore gains the standard addEventListener(), removeEventListener() and dispatchEvent() methods. Nothing else about the interface changes in this feature: its purpose is to give connection-level events a home on the object that represents the connection, starting with the separately proposed maxwritewithoutresponsesizechanged event.
The chromestatus milestone=157 listing files this feature under “Enabled by default”, and the detail record targets desktop, Android, WebView and iOS 157. However, the implementing change, Chromium CL 8363084, merged on 2026-11-13 at refs/heads/main@{#1743596}. According to ChromiumDash, that is after the M157 branch point (#1717349), the M158 branch point (#1727472) and the M159 branch point (#1739869), all queried 2026-11-15. Unless the change is merged back to a release branch (this page did not check for a merge-back), the first release that contains it will be later than 157. The defining spec change, WebBluetoothCG/web-bluetooth PR #672, is approved but not merged. There is no runtime flag for the inheritance: the : EventTarget in the Chromium IDL is unconditional, so detect the feature instead of checking the version number:
const serverIsEventTarget =
"BluetoothRemoteGATTServer" in globalThis &&
EventTarget.prototype.isPrototypeOf(BluetoothRemoteGATTServer.prototype);
at a glance
| Interface | BluetoothRemoteGATTServer (Web Bluetooth) |
|---|---|
| Change | Parent interface changes from none (prototype chain ends at Object.prototype) to EventTarget |
| New inherited members | addEventListener(), removeEventListener(), dispatchEvent() |
| New events | None in this feature. The first event designed for this target, maxwritewithoutresponsesizechanged, ships as a separate feature (CL 7879985) |
| Exposure | [Exposed=Window, SecureContext]; no workers |
| Flag | None (not gated by a runtime-enabled feature) |
| ChromeStatus | 5138797158334464 · tracking bug 40265040 · Intent to Ship |
| Spec | Web Bluetooth with PR #672 applied (preview); not yet in the published draft |
why it exists
BluetoothRemoteGATTServer represents an active GATT connection. Some state belongs to the connection rather than to the device or one characteristic: for example, the negotiated ATT_MTU, which limits how many bytes writeValueWithoutResponse() can send in one packet. Before this change the server object could not have listeners, so connection-level events had to be fired at BluetoothDevice (as gattserverdisconnected is). Making the server an EventTarget provides the standard listener API on the right object. The ChromeStatus record calls it a small preparation feature for that later work.
syntax
The interface as it reads with PR #672 applied (quoted verbatim from the PR preview, head 0d80357, read 2026-11-15). This feature is the : EventTarget on the first line. The other members are pre-existing, except maxWriteWithoutResponseSize and onmaxwritewithoutresponsesizechanged, which the same PR adds but which ship as a separate Chrome feature:
[Exposed=Window, SecureContext]
interface BluetoothRemoteGATTServer : EventTarget {
[SameObject]
readonly attribute BluetoothDevice device;
readonly attribute boolean connected;
readonly attribute unsigned short maxWriteWithoutResponseSize;
attribute EventHandler onmaxwritewithoutresponsesizechanged;
Promise<BluetoothRemoteGATTServer> connect();
undefined disconnect();
Promise<BluetoothRemoteGATTService> getPrimaryService(BluetoothServiceUUID service);
Promise<sequence<BluetoothRemoteGATTService>>
getPrimaryServices(optional BluetoothServiceUUID service);
};
The three members gained through inheritance, as declared on EventTarget in the DOM Standard:
[Exposed=*]
interface EventTarget {
constructor();
undefined addEventListener(DOMString type, EventListener? callback, optional (AddEventListenerOptions or boolean) options = {});
undefined removeEventListener(DOMString type, EventListener? callback, optional (EventListenerOptions or boolean) options = {});
boolean dispatchEvent(Event event);
};
Called on a server as server.addEventListener(type, callback, options), server.removeEventListener(type, callback, options) and server.dispatchEvent(event). The EventTarget constructor is not inherited as a way to create servers: BluetoothRemoteGATTServer declares no constructor of its own.
the inheritance contract
Per Web IDL, declaring : EventTarget makes Object.getPrototypeOf(BluetoothRemoteGATTServer.prototype) equal EventTarget.prototype, and makes the interface object’s own prototype EventTarget. The three methods are inherited, not copied: Object.hasOwn(BluetoothRemoteGATTServer.prototype, "addEventListener") stays false, and server.addEventListener === EventTarget.prototype.addEventListener. The interface still has no constructor; new BluetoothRemoteGATTServer() throws a TypeError.
member reference
| Member | Returns | Full reference |
|---|---|---|
addEventListener(type, callback, options) | undefined | BluetoothRemoteGATTServer.addEventListener() |
removeEventListener(type, callback, options) | undefined | BluetoothRemoteGATTServer.removeEventListener() |
dispatchEvent(event) | boolean | BluetoothRemoteGATTServer.dispatchEvent() |
inputs and observable effects
inputs
The inheritance change takes no arguments. It has no option, flag, header or permission to configure. All inputs go through the three inherited methods. addEventListener() and removeEventListener() take an event type string, a callback (a function, an object with handleEvent(), or null) and an optional options dictionary or capture boolean. dispatchEvent() takes an initialized Event object. The parameters are documented on each member page.
outputs and observable effects
server instanceof EventTargetbecomestrue;EventTarget.prototype.isPrototypeOf(BluetoothRemoteGATTServer.prototype)becomestrue.for…inover a server object now also yieldsaddEventListener,removeEventListeneranddispatchEvent. ChromeStatus lists this, along with code that relies on the methods being absent, as the only interop risk.- Listeners registered on the server can be inspected with the existing DevTools Console and event-listener tools. ChromeStatus says no dedicated panel is needed.
- The existing members (
device,connected,connect(),disconnect(),getPrimaryService(),getPrimaryServices()) behave exactly as before.
errors
The inheritance adds no new exception paths to Web Bluetooth. The errors you can now hit come from the inherited EventTarget methods and from Web IDL:
dispatchEvent(event)throws an"InvalidStateError"DOMExceptionifeventis already being dispatched or was never initialized (details).- Passing a non-
EventtodispatchEvent(), or calling an inherited method with athisthat is not anEventTarget, throws aTypeError. new BluetoothRemoteGATTServer()still throwsTypeError: Illegal constructor. Server objects only come fromBluetoothDevice.gatt.- On a browser without the change,
server.addEventListenerisundefined, so calling it throwsTypeError: server.addEventListener is not a function. Use the feature check in the note above.
new BluetoothRemoteGATTServer() threw TypeError: Failed to construct 'BluetoothRemoteGATTServer': Illegal constructor, and the prototype’s parent was Object.prototype.
context and exposure
- Global:
Windowonly, and only in a secure context ([Exposed=Window, SecureContext]). Not exposed in workers. - Getting a receiver: a server comes from
device.gatt, anddevicecomes fromnavigator.bluetooth.requestDevice()(which needs a user gesture and a chooser) orgetDevices(). Thegattgetter returnsnullin the spec unless the origin may use GATT on that device. - Policy: the document must be allowed to use the
"bluetooth"policy-controlled feature. This is unchanged. - Platforms: the ChromeStatus record lists desktop, Android, WebView and iOS. However, BCD records no Android WebView support for
BluetoothRemoteGATTServer, and Chrome on iOS has no Web Bluetooth. Where the interface does not exist, this change has nothing to attach to. - Feature detection: works without hardware or permission, using the prototype check in the note above.
lifecycle and event flow
- One server object per device:
device.gattreturns the device’s stored[[gatt]]object, so a listener attached to the server stays attached acrossdisconnect()/connect()cycles. Attach it once instead of after every reconnect. Otherwise the same handler is added again, unless you pass the same function reference, whichaddEventListener()de-duplicates. - No propagation: the server is not part of the Bluetooth tree. That tree includes
navigator.bluetooth, devices, services, characteristics and descriptors. ABluetoothRemoteGATTServeruses the default get the parent, which returns null. Events dispatched at a server reach only the server’s own listeners, even withbubbles: true, and events on the device or its services never pass through the server. - Which object fires what:
gattserverdisconnectedis still fired atBluetoothDevice, not at the server; listen ondevicefor disconnects.availabilitychangedfires atnavigator.bluetoothandcharacteristicvaluechangedat characteristics. The only event the spec defines for the server ismaxwritewithoutresponsesizechanged, in the same PR. That event and itsonmaxwritewithoutresponsesizechangedhandler ship as a separate feature behind Chromium’sWebBluetoothMaxWriteWithoutResponseSizeruntime flag (CL 7879985). Until that ships, nothing in Chrome fires at the server except events you dispatch yourself. - Teardown: Chromium resolves the server’s execution context through its device (
GetExecutionContext()returnsdevice_->GetExecutionContext()in CL 8363084), so listeners go away with the document. Within a page, remove them withremoveEventListener()or anAbortSignal.
examples
detect, connect and listen on the server
Run this from a click handler on an HTTPS page. It attaches connection-level listeners to the server once and keeps disconnect handling on the device, where that event actually fires:
const button = document.querySelector("#connect");
button.addEventListener("click", async () => {
if (!("bluetooth" in navigator)) {
console.log("Web Bluetooth is not available here.");
return;
}
const device = await navigator.bluetooth.requestDevice({
filters: [{ services: ["battery_service"] }],
});
const server = device.gatt; // the same object on every access
// Disconnects are still fired at the device.
device.addEventListener("gattserverdisconnected", () => {
console.log("disconnected; server listeners stay attached");
});
if (EventTarget.prototype.isPrototypeOf(BluetoothRemoteGATTServer.prototype)) {
// Connection-level events go to the server. This is the first
// event type designed for it (shipped as a separate feature).
server.addEventListener("maxwritewithoutresponsesizechanged", () => {
console.log("new size:", server.maxWriteWithoutResponseSize);
});
}
await server.connect();
console.log("connected:", server.connected);
});
use the server as an app-level event bus
Because the server is now an EventTarget, your own connection code can dispatch synthetic events at it. They do not propagate, and isTrusted is false:
function announceReady(server) {
server.dispatchEvent(new CustomEvent("app:ready", { detail: { at: Date.now() } }));
}
const controller = new AbortController();
server.addEventListener("app:ready", (event) => {
console.log(event.target === server, event.isTrusted, event.detail.at); // true false …
}, { signal: controller.signal });
announceReady(server);
controller.abort(); // detaches the listener
browser compatibility
| Browser | BluetoothRemoteGATTServer (BCD) | Inherits EventTarget |
|---|---|---|
| Chrome (desktop) | 70 (partial: Linux not enabled by default); 56–69 macOS only | Listed for 157 (interim, ChromeStatus); code merged after the M159 branch point, so the first release is unknown |
| Chrome Android | 56 | Listed for 157 (interim); same caveat |
| Edge | Mirrors Chrome | Unknown (not separately reported) |
| Opera / Samsung Internet | Mirror Chrome | Unknown |
| Android WebView | No (version_added: false) | Not applicable (no interface), despite the ChromeStatus WebView milestone |
| Firefox | No (bug 674737) | No |
| Safari / iOS | No (WebKit bug 101034) | No |
The interface column comes from BCD api/BluetoothRemoteGATTServer.json (fetched raw 2026-11-15; status experimental, standard_track). BCD has no key for the inheritance change. The methods themselves have been on EventTarget for a long time per BCD api/EventTarget.json. The inheritance column is therefore interim data from ChromeStatus, corrected by the CL position given in the shipping note. Mozilla’s position on Web Bluetooth is negative and WebKit’s is oppose. Both cover the whole API, not this change.
security and privacy
This change exposes only the standard EventTarget methods on an object the page could already reach. It does not give access to any more devices, services, characteristics, data or operations. The existing protections are unchanged: the permission chooser, the secure-context requirement, the service allowlist, the GATT blocklist and the "bluetooth" Permissions Policy. Events you dispatch yourself have isTrusted set to false and cannot be mistaken for UA-fired events. Registering a listener does not connect to the device or keep it connected. The only new observable is the prototype chain itself, which shows whether the browser has this change and reveals nothing about Bluetooth hardware or paired devices. ChromeStatus lists the security and privacy reviews as “Pending” (queried 2026-11-15).
specifications
| Specification | Status |
|---|---|
| Web Bluetooth (with PR #672) §BluetoothRemoteGATTServer | Approved pull request, not merged (PR #672, head 0d80357 on 2026-11-02) |
| Web Bluetooth §6.2 BluetoothRemoteGATTServer | Draft Community Group Report (3 June 2026). It still declares the interface without a parent |
| DOM Standard §2.7 Interface EventTarget | Living Standard |
see also
- chromestatus — Web Bluetooth: Make BluetoothRemoteGATTServer an EventTarget (5138797158334464)
- blink-dev: Intent to Ship
- WebBluetoothCG/web-bluetooth PR #672 (explainer and spec change)
- Chromium CL 8363084 · Chromium issue 40265040
- Tests: Chromium global-interface-listing · WPT Web Bluetooth idlharness
- MDN: BluetoothRemoteGATTServer (does not yet mention
EventTarget, checked 2026-11-15) · MDN: EventTarget - Member references:
addEventListener()·removeEventListener()·dispatchEvent() - chrome-platform-showcase: four concept demos for this feature