# @d-gs/vue-pwa-install-prompt

> PWA Install Prompt For Vue3.

Latest version **0.1.6** (published 2021-12-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @d-gs/vue-pwa-install-prompt
pnpm add @d-gs/vue-pwa-install-prompt
yarn add @d-gs/vue-pwa-install-prompt
bun add @d-gs/vue-pwa-install-prompt
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2021-12-11 |
| First published | 2021-12-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | __d |
| Maintainers | d-gs |
| Keywords | vue, plugin, pwa, install, prompt |

## Links

- npm: https://www.npmjs.com/package/@d-gs/vue-pwa-install-prompt
- Repository: https://github.com/glamseam/vue-pwa-install-prompt
- Homepage: https://github.com/glamseam/vue-pwa-install-prompt#readme
- Issues: https://github.com/glamseam/vue-pwa-install-prompt/issues
- npm.io page: https://npm.io/package/@d-gs/vue-pwa-install-prompt

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 0.1.6 (latest) — 2021-12-11
- 0.1.5 — 2021-12-10
- 0.1.4 — 2021-12-09
- 0.1.3 — 2021-12-09
- 0.1.2 — 2021-12-09
- 0.1.1 — 2021-12-09
- 0.1.0 — 2021-12-09

## README

# vue-pwa-install-prompt

PWA Install Prompt For Vue3. (Not supported Vue2)

# Install

```sh
npm i @d-gs/vue-pwa-install-prompt
```

# Usage

In `index.html`

```html
  <head>
    ...
    <link rel="manifest" href="/manifest.webmanifest" />
  </head>
```

In `app.ts`

```ts
import { pluginPwaInstallPrompt } from '@d-gs/vue-pwa-install-prompt'
app.use(pluginPwaInstallPrompt)
```

In `App.vue`

```vue
<script lang="ts" setup>
import { usePwaInstallPrompt } from '@d-gs/vue-pwa-install-prompt'
import type { BeforeInstallPromptEvent } from '@d-gs/vue-pwa-install-prompt'

const pwaInstallPrompt = usePwaInstallPrompt()

// Service Worker
if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/sw.js')
    .then((reg) => {
      reg.onupdatefound = () => {
        reg.update()
      }
    })

  window.addEventListener('beforeinstallprompt', (event) => {
    event.preventDefault()
    pwaInstallPrompt.actions.setInstallPromptEvent(event as BeforeInstallPromptEvent)
  })
}
</script>
```

In `Comp.vue`

```vue
<script lang="ts" setup>
import { usePwaInstallPrompt } from '@d-gs/vue-pwa-install-prompt'

const pwaInstallPrompt = usePwaInstallPrompt()
const showPrompt = async () => {
  const outcome = await pwaInstallPrompt.actions.showPrompt()
  // outcome: 'accepted' | 'dismissed' | undefined

  if (outcome === 'accepted') {
    // Do something
    return
  }

  if (outcome === 'dismissed') {
    // Do something
    return
  }
}
</script>
```

---
_Source: https://npm.io/package/@d-gs/vue-pwa-install-prompt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
