Meteor and Service Workers


#1

It looks like service workers and related APIs like fetch stand a good chance at becoming the de facto way at implementing offline-first apps.

http://www.html5rocks.com/en/tutorials/service-worker/introduction/

How can we integrate with service workers from Meteor? How would something like minimongo interact with it? Service workers’ navigation seems to be based on REST-like APIs or at least endpoints, which Meteor doesn’t expose, so a package that allows us to still write against the Meteor API but get offline support with service workers could be quite nice.


#2

Now that Service Worker is in Chrome, someone wrote this pretty nice plugin for Webpack: https://github.com/NekR/offline-plugin

It would be really nice to have something similar to this or the existing meteor appcache package, where just adding it to the project makes your app serviceworker-compatible.

Anyone up to the challenge? :smile:


#3

Love this thread. For the record, a small vid explaining Service Worker: https://www.youtube.com/watch?v=SmZ9XcTpMS4


#4

Progressive Web Apps in Meteor
#5

Are there any news on this? Especially regarding the “add to home screen” functionality this would be valuable for us.


#6

Note that service workers are not supported on ios.


#7

How about integrating this package - https://www.npmjs.com/package/sw-toolbox referencing https://slightlyoff.github.io/ServiceWorker/spec/service_worker/ or maybe finding some similar package.


#8

Progressive Web Apps and Service Workers are getting a lot of attention at the moment. I found this talk form Google I/O particularly engaging.

I’d be very interested to understand how we can best take advantage of this approach for Meteor based apps, and what plans, if any MDG has to integrate and/or enable them.


#9

I personally think this is an important topic for Meteor and here is my humble opinion on this…

Service workers allows granular caching and better user experience in offline mode and adds the support for push notifications, in addition we’ve the ability to add to home screen using the manifest file, components lazy loading using “PRPL” pattern and HTTP/2 support, speed loading the application shell then lazy load the data and the rest of the app are all technologies and design patterns that pushes the mobile web forward.

With such powerful set of technologies in the pipeline it seems that in the future we’ll have less use of Cordova to build connected clients and more progressive web apps will be created.

I think Meteor is the right framework to pioneer the support for those technologies since it made connected clients first class citizen of the web early on…


#10

Service worker matters. Even I’m not sure package API could allow me to register a file to root you can use my Meteor service worker with instructions to put it by yourself in /public and register it here :
https://github.com/NitroBAY/meteor-service-worker (it’s still in an early phase).
Please tell me what you think about it.


#11

@nitrobay, thanks a lot for this effort! Indeed, AppCaches are becoming a thing of the past and frankly have major issues. Would you consider your meteor-service-worker production-ready? Tested it and working great so far. Is it still maintained (can we help in anyway). I think this is important for Meteor to be at the forefront of modern web applications.


#12

Hello,
We’re already talking with Ramez on github so if other people see that thread :
AppCaches is indeed a thing of the past so Meteor’s team should support workers https://github.com/meteor/meteor/issues/5982
The repo is still maintained


#13

Thanks @nitrobay, your code is working great! Next, I feel we need two things

  1. We need to explain a bit better requirements on the server side for caching, and help people know it’s working with dev tools
  2. Incorporate approach similar to upup.js to allow fully offline app / prevent needless hit to load from server (when I hit reload it still fetches first HTML from meteor site)

I can help with #1, will need to agree with you on #2


#14

Just wanted to update the thread with a link to the current feature request to implement Service Workers in Meteor.


#15

i’ve setup a pwa_manifest.json in my meteor app, but when i add the icon to home screen there is a few seconds delay, and in chrome tool there is a message :

Site cannot be installed: no matching service worker detected. You may need to reload the page, or check that the service worker for the current page also controls the start URL from the manifest

what is the nowadays advice for meteor 1.8 ? should i install the @nitrobay from github? or should i just add something in my manifest ?

{ "name": "my test 123",
  "short_name": "test",
  "start_url": "./",
  "display": "standalone",
  "scope": "./",
  "background_color": "#ffffff",
  "theme_color": "#404080",
  "icons": [{ "src": "./img/icon_192.png", "sizes": "192x192", "type": "image/png" }] }