<!-- Generated by scripts/gen-docs.mts from the JSDoc in registry/. Do not edit; run `pnpm run docs`. -->

# useInstallPrompt

Whether the browser offers to install this web app, and the means to offer it at a good moment rather than when the browser chooses: `install()` opens the browser's own install dialog, `dismiss()` puts the offer away for two weeks. It is `available` only where the browser fires `beforeinstallprompt` (Chromium on Android and desktops; not Safari or Firefox), and never while the app already runs installed.

```tsx
import { useInstallPrompt } from "@/lib/ouro/use-install-prompt";
```

## Example

```tsx
const { available, install } = useInstallPrompt();
if (available) return <Button onClick={install}>Install the app</Button>;
```

## Use instead when

- Use `InstallPrompt` instead for the whole offer, a card with Install and Not now.

## Parameters

| Parameter | Type | Default |
| --- | --- | --- |
| `{ remindAfterDays = 14, storageKey = "ouro-install-dismissed" }` | `InstallPromptOptions` | `{}` |

## Returns

`InstallPromptState`

## Types

### `InstallPromptOptions`

Options for `useInstallPrompt`.

```ts
interface InstallPromptOptions {
  /** Days to wait before offering again after the person says not now. @default 14 */
  remindAfterDays?: number | undefined;
  /** The `localStorage` key that keeps when the person last said not now. @default "ouro-install-dismissed" */
  storageKey?: string | undefined;
}
```

### `InstallPromptState`

What `useInstallPrompt` returns.

```ts
interface InstallPromptState {
  /** Whether to offer installing now: the browser can install the app, it is not installed, and the person has not said not now lately. */
  available: boolean;
  /** Whether the app runs installed (standalone) or was installed from this page. */
  installed: boolean;
  /** Opens the browser's install dialog and resolves how the person answered. */
  install: () => Promise<"accepted" | "dismissed" | "unavailable">;
  /** Hides the offer and remembers it for `remindAfterDays`. */
  dismiss: () => void;
}
```
