Valyrian.js 5.0.8

Get started - Service worker plugin

What is Valyrian.js?InstallationHyperscript/JSXComponentsLifecycle methodsDirectivesServer side jsxPlugins

Service worker plugin


This plugin is available with the main valyrian.js package, so, you only need to add it with thev.usePlugin() method.
let Sw = require('valyrian.js/plugins/sw.js');



The service worker plugin is a helper plugin that just adds a convenience method to register a service worker.
If it's called without any params, it defaults to register ./sw.js file with{scope: '/'} options passed to the navigator.serviceWorker.register method.
It returns a Promise that resolves with the service worker object.
// v.sw(file = './sw.js', options = {scope: '/'})
if (!v.isNode){
If you use server-side renderign remember to first validate that you are in a browser environment before call this method.