Next-pwa: Always return an app-shell when user if offline.

Created on 6 May 2020  路  3Comments  路  Source: shadowwalker/next-pwa

One of the main benefits of a PWA is that all URLs respond with a 200 and a working app shell.

In an ideal scenario a nextjs PWA would respond with an app-shell which could be created by a user by accessing something like /pages/_app-shell.js (which can have 'blank' default like _404 is)

When a user accesses a random URL it will always return the contents of _app-shell.js. The client app will navigate to the page if the user is online, if the user is offline offline it wont and it will show a 'you are offline message'.

Most helpful comment

Isn't this something that would be in the scope of next-pwa to support in the plugin its self?

Currently the plugin is purely a service worker implementation. Maybe that is the goal, but that contradics the 'Zero Config PWA Plugin for Next.js' slogan ;)

All 3 comments

I think what you are looking for is navigateFallback in workbox config
https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-webpack-plugin.GenerateSW#GenerateSW

Feel free to pass this config into pwa object in next.config.js

Isn't this something that would be in the scope of next-pwa to support in the plugin its self?

Currently the plugin is purely a service worker implementation. Maybe that is the goal, but that contradics the 'Zero Config PWA Plugin for Next.js' slogan ;)

@paales yes! I agree too. Basic pwa checklist fails if this case is not handled.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mohammadgarmroodi picture mohammadgarmroodi  路  5Comments

loyep picture loyep  路  3Comments

adammesa picture adammesa  路  8Comments

maximousblk picture maximousblk  路  7Comments

jonahsnider picture jonahsnider  路  4Comments