An open API service indexing awesome lists of open source software.

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

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