pwa-popup

@vuepress/plugin-pwa-popup

Provide a popup component for users to activate the new PWA service worker manually.

This plugin must be used together with pwa plugin, and the skipWaiting option must not be set to true.

When the new service worker is ready, a popup will appear in the right bottom of the page to ask users to activate the waiting service worker.

Options

locales

  • Type: Record<string, { message: string, buttonText: string }>

  • Details:

    The messages of the popup in different locales.

    If this option is not specified, it will fallback to default messages.

  • Example:

module.exports = {
  plugins: [
    ['@vuepress/plugin-pwa'],
    [
      '@vuepress/plugin-pwa-popup',
      {
        locales: {
          '/': {
            message: 'New content is available.',
            buttonText: 'Refresh',
          },
          '/zh/': {
            message: '发现新内容可用',
            buttonText: '刷新',
          },
        },
      },
    ],
  ],
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Styles

You can customize the style of the popup via CSS variables:

:root {
  --pwa-popup-z-index: 10;

  --pwa-popup-text-color: #2c3e50;
  --pwa-popup-bg-color: #ffffff;
  --pwa-popup-border-color: #3eaf7c;
  --pwa-popup-shadow: 0 4px 16px var(--pwa-popup-border-color);

  --pwa-popup-btn-text-color: #ffffff;
  --pwa-popup-btn-bg-color: #3eaf7c;
  --pwa-popup-btn-hover-bg-color: #4abf8a;
}
1
2
3
4
5
6
7
8
9
10
11
12