Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qvil/use-pwa-install
React hook for PWA(Progressive Web App) install
https://github.com/qvil/use-pwa-install
hook hooks install pwa react reactjs
Last synced: 14 days ago
JSON representation
React hook for PWA(Progressive Web App) install
- Host: GitHub
- URL: https://github.com/qvil/use-pwa-install
- Owner: qvil
- License: mit
- Created: 2022-06-23T16:27:35.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-06-28T18:10:04.000Z (over 2 years ago)
- Last Synced: 2025-01-19T13:36:53.530Z (23 days ago)
- Topics: hook, hooks, install, pwa, react, reactjs
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/use-pwa-install
- Size: 305 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# use-pwa-install
[![CI](https://github.com/qvil/use-pwa-install/actions/workflows/main.yml/badge.svg)](https://github.com/qvil/use-pwa-install/actions/workflows/main.yml)
React hook for PWA(Progressive Web App) install
## Demo
![Demo](example/demo.gif)
## Install
```
npm i use-pwa-install
```## Usage
```js
import React from 'react';
import usePWAInstall from 'use-pwa-install';const App = () => {
const { isInstalled, install } = usePWAInstall();return (
{isInstalled ? (
App is installed
) : (
Install
)}
);
};
```## Options
| options | Type | Description | Required | Default Value |
| ----------- | -------- | ------------------------------------------- | -------- | ------------- |
| acceptedFn | Function | Callback function to execute when accepted | no | console.log() |
| dismissedFn | Function | Callback function to execute when dismissed | no | console.log() |
| installedFn | Function | Callback function to execute when installed | no | console.log() |## Return value
| value | Type | Description |
| ----------- | -------- | -------------------- |
| isInstalled | boolean | Install state |
| install | Function | App install function |## Browser compatibility
- https://developer.mozilla.org/en-US/docs/Web/API/BeforeInstallPromptEvent#browser_compatibility
- https://developer.mozilla.org/en-US/docs/Web/API/Window/appinstalled_event#browser_compatibility