new PushEvent(type, options) creates a PushEvent — the object behind push and pushsubscriptionchange in the Push API. Per MDN, the constructor is exposed only to a service worker context.
Pass the required arguments shown below. Use only in a service worker (secure context). Prefer listening for push over constructing events in production.
Syntax
Create a PushEvent. Start with this line.
JavaScript
new PushEvent(type, options?)
Call
What it does
new PushEvent(type, options?)
Primary signature.
Built into the service worker. Call new PushEvent(...) — no import required.
Library declarations
JavaScript
new PushEvent(type, options?)
Parameters
Parameter
Description
type
Required. Event name — usually "push" or "pushsubscriptionchange"
options.data
Optional. Payload bytes wrapped as PushMessageData
options (Event fields)
Optional. Also accepts ExtendableEvent / Event fields such as bubbles
Return Value
Return Value
Description
*
A new PushEvent object
JavaScript Examples
Example 1 — MDN Text data
Create a push event with a string payload and read it with text().
The PushEvent() constructor is Baseline Widely available (MDN, since March 2023). It requires a secure context and is exposed only in service workers.
✓ Baseline · Widely available
PushEvent() constructor
Create PushEvent objects in service workers for the Push API.
WideModern browser support
Google ChromeSupported · Service worker
Full support
Mozilla FirefoxSupported · Desktop & Android
Full support
Apple SafariSupported · modern Safari / iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
OperaFollow Chromium
Full support
Internet ExplorerNo PushEvent / service workers
Not supported
PushEvent()Widely available
Bottom line: Supported in current Chrome, Firefox, Safari, and Edge. Always use HTTPS (or localhost) and a service worker. Internet Explorer has no Push API.
Frequently Asked Questions
new PushEvent(type, options) creates a PushEvent object. It is exposed only in a service worker context and represents a push message (or subscription change) in the Push API.
No. MDN marks the PushEvent() constructor as Baseline Widely available (since March 2023). It is not Deprecated, Experimental, or Non-standard.
Only inside a service worker global scope, in a secure context (HTTPS or localhost). It is not available on the main window thread.
The type is case-sensitive. Browsers set it to push for incoming push messages and pushsubscriptionchange when a push subscription changes (MDN).
An optional payload (string, ArrayBuffer, Blob, and similar). The resulting PushEvent.data property is a PushMessageData object you can read with text(), json(), arrayBuffer(), or blob().
addEventListener listens for push events the browser delivers. The constructor lets you create a PushEvent manually—useful for tests or learning how event.data is shaped.