LitePushClientConfig

interface
PropertyTypeDescription
projectIdstring

Project ID from the dashboard (prj_*).

vapidKeystring

The project's VAPID public key.

apiBase?string

Override the API origin. Defaults to https://api.litepush.dev.

swPath?string

Path the service worker is served from on your origin. Defaults to /litepush-sw.js.

LitePushClient

class

Constructor

constructor(config):LitePushClient
ParameterTypeDescription
configLitePushClientConfig

Properties

readonlyprojectId:string
readonlyvapidKey:string
readonlyapiBase:string
readonlyswPath:string
readonlyversion:"0.0.0"

Methods

canSubscribe():boolean

Whether this browser can actually complete a subscribe. Synchronous, safe anywhere.

isSubscribed():Promise<boolean>

Whether this browser currently has an active subscription for the project.

subscribe(opts?):Promise<SubscribeResult | null>

Request permission (if needed), register the service worker, create a PushSubscription, and register it with LitePush. Returns { id } on success or null if the user denied permission. Must be called from a user gesture. Throws on unsupported browsers — gate on canSubscribe().

ParameterTypeDescription
opts?SubscribeOptionsdefault: {}
unsubscribe():Promise<boolean>

Cancel the current browser's subscription and beacon /v1/unsubscribe so the dashboard updates immediately. Returns true if a subscription was actually removed.

canSubscribe

function
canSubscribe():boolean

VERSION

const
"0.1.0"

Re-exports

This entry point also re-exports the following shared types: