registerSw
Registers a service worker file for the application.
Table of contents
Category
Value
Import
jsimport { registerSw } from "valyrian.js/sw";Public signature
tsregisterSw(file?: string, options?: RegistrationOptions, navigatorRef?: Navigator | null): Promise<ServiceWorkerRegistration | undefined>API form
registerSw is an asynchronous function. It registers one service worker and returns its registration.
Defaults and result
tsfile = "./sw.js"
options = { scope: "/" }
navigatorRef = globalThis.navigator
Promise<ServiceWorkerRegistration | undefined>Unavailable runtime
When the selected navigator has no serviceWorker API, registerSw resolves undefined without registering a worker. Registration failures reject the returned promise.