https://github.com/qvil/use-before-install-prompt
React hook for beforeinstallprompt event
https://github.com/qvil/use-before-install-prompt
Last synced: 2 months ago
JSON representation
React hook for beforeinstallprompt event
- Host: GitHub
- URL: https://github.com/qvil/use-before-install-prompt
- Owner: qvil
- License: mit
- Created: 2022-06-22T17:16:29.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-25T02:16:59.000Z (almost 4 years ago)
- Last Synced: 2025-01-28T02:19:10.955Z (over 1 year ago)
- Language: TypeScript
- Size: 126 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# This project has been deprecated. Move to [use-pwa-install](https://www.npmjs.com/package/use-pwa-install)
# use-before-install-prompt
React hook for beforeinstallprompt event
## Install
```
npm i use-before-install-prompt
```
## Usage
```js
import React from 'react';
import useBeforeInstallPrompt from 'use-before-install-prompt';
const App = () => {
const { isInstalled, addToHomeScreen } = useBeforeInstallPrompt();
return (
<>
{!isInstalled && (
Add to home screen
)}
>
);
};
```
## 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 |
| addToHomeScreen | Function | Add to home screen function |
## Browser compatibility
https://developer.mozilla.org/en-US/docs/Web/API/BeforeInstallPromptEvent#browser_compatibility