Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@kevinmarrec/nuxt-pwa

kevinmarrec12.7kMITdeprecated0.17.0TypeScript support: included

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

Zero config PWA solution for Nuxt 3

nuxt, pwa, module

readme

Nuxt 3 PWA

npm version npm downloads Github Actions Codecov

Zero config PWA solution for Nuxt 3

image

State of official module

This module is unofficial but aims to become the next iteration of the official Nuxt PWA module.

Setup

Add @kevinmarrec/nuxt-pwa dependency to your project :

# Using Yarn
yarn add -D @kevinmarrec/nuxt-pwa
# Using NPM
npm install -D @kevinmarrec/nuxt-pwa
# Using PNPM
pnpm install -D @kevinmarrec/nuxt-pwa

Edit your nuxt.config.ts file to add PWA module :

export default defineNuxtConfig({
  modules: [
    '@kevinmarrec/nuxt-pwa'
  ]
})

Configuration

As this module tries to be compliant with Nuxt 2 PWA for easy migration, you can still use https://pwa.nuxtjs.org documentation for most features.

If you want your app to be installable in development, you need to set pwa.workbox.enabled option to true in your nuxt.config, as it's only enabled for production by default :

export default defineNuxtConfig({
  modules: [
    '@kevinmarrec/nuxt-pwa'
  ],
  pwa: {
    workbox: {
      enabled: true
    }
  }
})

If you need custom workbox service worker, you can specify path to your worker with pwa.workbox.templatePath option, you can use path aliases like ~ and @.

export default defineNuxtConfig({
  modules: [
    '@kevinmarrec/nuxt-pwa'
  ],
  pwa: {
    workbox: {
      templatePath: '~/path/to/your/worker.js'
    }
  }
})

To customize it, you can check the default of this module here, as well as Nuxt 2 default and Workbox Documentation.

Composables

usePWAIcon (size, options)

You can use usePWAIcon to get icons urls of your PWA, and use it in your app.

const icon = usePWAIcon(512) // /assets/icons/512x512.png
const icon = usePWAIcon(512, { maskable: true }) // /assets/icons/512x512.maskable.png

Alternatively, you can benefit of available sizes with Typescript using a string instead of number size parameter :

image

Development

Make sure to install the dependencies :

pnpm install

Start the development server on http://localhost:3000 :

pnpm dev

Example

Build & start example on http://localhost:3000 :

pnpm example:build
pnpm example:start

License

Made with ❤️

Published under the MIT License.

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.17.0 (2023-03-02)

Bug Fixes

0.16.2 (2023-02-08)

Bug Fixes

  • icon: rebuild cache if icon options change (17dfeb8), closes #77

0.16.1 (2023-02-05)

Bug Fixes

0.16.0 (2023-02-04)

Features

  • workbox: auto unregister when not enabled (#92) (5b45153)

0.15.0 (2023-01-12)

Features

  • manifest: add manifest meta crossorigin attribute (#87) (c430214)

Bug Fixes

  • meta: improve appleStatusBarStyle types (1f318d8), closes #85

0.14.1 (2023-01-10)

Bug Fixes

0.14.0 (2023-01-05)

Features

Bug Fixes

  • use consola level raw value for silent mode (52372de)

0.13.0 (2022-11-23)

0.12.0 (2022-11-23)

Features

  • meta: add hid to all meta tags (faa5ad6)

0.11.1 (2022-11-17)

Bug Fixes

  • meta: twitter image should use ogHost (f1c0698)

0.11.0 (2022-11-17)

Bug Fixes

  • meta: better title behavior (with opt out) (fe1b47d)

0.10.0 (2022-11-07)

Features

  • sw: include web manifest in assets strategy (#59) (4326eba)

0.9.1 (2022-10-22)

Bug Fixes

  • prevent title override when titleTemplate is used (8b66b07)

0.9.0 (2022-10-22)

Features

  • add missing optional properties to ManifestOptions interface (#55) (0779344)

Bug Fixes

  • meta: ability to opt-out theme_color property (ee3070e), closes #53
  • meta: prevent title override (e637b0f)

0.8.0 (2022-10-12)

Features

  • icon: add icon.maskableSource option (#51) (84cb83d)

0.7.2 (2022-10-11)

Bug Fixes

  • improve nitro config to fix nuxi generate (b322220)

0.7.1 (2022-10-11)

Bug Fixes

  • add missing import in nitro plugin (1c1b3e2)

0.7.0 (2022-10-11)

Features

  • add workbox.autoRegister option (76ecf22), closes #46

Bug Fixes

  • use nitro plugin for sw registration (79063ef), closes #45

0.6.1 (2022-10-01)

Bug Fixes

  • icon: support all icon sizes (f342fa8)

0.6.0 (2022-10-01)

Features

0.5.0 (2022-09-29)

Features

Bug Fixes

  • generate manifest.json when ssr is disabled (8c52b11), closes #32
  • icon: better unusual input icon handling (8c1f8e2), closes #40

0.4.2 (2022-07-22)

Bug Fixes

  • remove postinstall command (d67bbc6), closes #23

0.4.1 (2022-07-22)

Bug Fixes

  • manifest: move server handler to runtime (73ee968), closes #22

0.4.0 (2022-07-22)

Bug Fixes

  • prevent assets duplication on build (e54f564), closes #20

0.3.1 (2022-06-24)

Bug Fixes

  • disable icon generation on stackblitz (7813821)

0.3.0 (2022-06-07)

Features

Bug Fixes

  • use baseURL for sw/manifest/icons/splash (#14) (aa01db1)
  • workbox: fix worker when using pages folder (52ecdb9), closes #11

0.2.2 (2022-06-01)

Bug Fixes

  • adjust manifest icons purposes (f01b0a5), closes #8

0.2.1 (2022-05-31)

Bug Fixes

  • move sw.js on root to make app installable (bd36561)

0.2.0 (2022-05-31)

Features

0.1.0 (2022-05-21)

Features

  • add icon generation & asset hashing (#2) (a6ccb95)

0.0.2 (2022-05-15)

Bug Fixes

  • types: add short_name to ManifestOptions (72ab2ce)

0.0.1 (2022-05-15)