Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I have multiple PWAs on the same domain under different URL paths?

For example, can I create a PWA under example.com/todo-app, another one under example.com/time-tracking-app, and have each as a completely separate app that can be "installed" with a different icon on the home screen, have its own separate notifications, etc.?

like image 644
agentofuser Avatar asked Nov 25 '17 13:11

agentofuser


People also ask

Can PWA have multiple pages?

There is no requirement for a PWA to be a SPA. In fact, many pages like news sites or web shops are much better suited as multi page applications. When building a multi page PWA, be sure to: Load the ServiceWorker with a scope that covers the entire site.

Does PWAs run in browser?

PWAs run in browsers, like websites. But PWAs also have access to app features; for example: A PWA can still work when the device is offline. PWAs can be installed on the operating system.


1 Answers

You can do it if each separate PWA has:

  • a link to a different manifest
  • uses Service Workers that have non-overlapping scopes. That means you have to register them with scopes that look something like navigator.serviceWorker.register('/sw.js', {scope: './todo-app/'}) and navigator.serviceWorker.register('/sw.js', {scope: './time-tracking-app/'})

In general I'd advise against doing this because if you make any mistakes later on with scopes you'll have issues that will be very hard to debug.

like image 85
ade Avatar answered Oct 11 '22 09:10

ade