Permission Pre-Ask

Permission Pre-Ask is a copy-paste React component that stops wasted the browser's one permission prompt before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/permission-pre-ask
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsWasted the browser's one permission prompt

Was this component page useful?

How do I install Permission Pre-Ask?

pnpm dlx shadcn@latest add @bollard/permission-pre-ask

The files land in your project. They're yours to edit.

How do I use Permission Pre-Ask in React?

permission-pre-ask-usage.tsx
import { PermissionPreAsk, type PermissionResult } from "@/components/ui/permission-pre-ask"

<PermissionPreAsk
  permission="notifications"
  reason="Only when your order ships or a delivery is running late. No offers, and you can turn it off anytime."
  query={prompt}
  request={request}
  browser="chrome"
/>

What input mistakes does Permission Pre-Ask catch?

  • Spending the browser prompt before the user knows why
  • Closed prompt vs permanent block
  • Browser-specific steps to turn a blocked permission back on (iOS uses Settings)
  • Permission granted later from settings: detected

What props does Permission Pre-Ask accept?

PermissionPreAsk props
PropTypeDefault
permission* (required)

Which browser permission this asks for.

PermissionKind—
reason* (required)

Why you need it and what for, in the user's terms. Shown before the browser prompt.

React.ReactNode—
title

Heading of the pre-ask.

stringTITLES[permission]
onGranted

Called once the permission is granted, whether just now or later from browser settings.

() => void—
onDecline

Called when the user picks "Not now"; the browser prompt has not been used up.

() => void—
query

Override how the state is read (tests, native wrappers).

(permission: PermissionKind) => Promise<PermissionResult>queryPermission
request

Override how the real prompt is shown.

(permission: PermissionKind) => Promise<PermissionResult>requestPermission
browser

Browser whose re-enable steps to show; detected when omitted.

BrowserName—
allowLabel

Button text to ask the browser.

string"Turn on"
laterLabel

Button text to decline for now.

string"Not now"
waitingText

Shown while the browser prompt is open.

string"Choose Allow in your browser's prompt, near the address …
dismissedText

Shown when the prompt was closed without a choice.

string"You closed the browser's prompt without choosing."
blockedTitle

`{noun}` and `{is}` (is/are) are filled in.

string"{noun} {is} blocked for this site"
recheckLabel

Button text to check again after changing settings.

string"I've turned it on"
askAgainLabel

Button text to ask again after a dismissal.

string"Ask again"

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Permission Pre-Ask accessible?

  • Container uses role=status; the blocked panel is a labelled region
  • Icons are aria-hidden
  • Allow and Not now are buttons

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

  • The Permissions API doesn't report every permission in every browser
  • Re-enable steps are written for major browsers and can drift as they change
  • Can't re-show the browser prompt once blocked

What expensive mistakes does Permission Pre-Ask stop?

Wasted the browser's one permission prompt

Also known as

permissions · notifications · camera · microphone · location · geolocation · push · priming

What dependencies does Permission Pre-Ask require?

Permission Pre-Ask facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component namePermission Pre-Ask
Registry identifier@bollard/permission-pre-ask
Install commandnpx shadcn@latest add @bollard/permission-pre-ask
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Permission Pre-Ask

What form validation mistake does Permission Pre-Ask catch?

Permission Pre-Ask prevents wasted the browser's one permission prompt. Explains why a permission is needed before the browser's one-shot prompt, and shows this browser's re-enable steps if it is blocked. Catches: Spending the browser prompt before the user knows why, Closed prompt vs permanent block, Browser-specific steps to turn a blocked permission back on (iOS uses Settings), Permission granted later from settings: detected. Limitation: validate permission-pre-ask schemas on backend.

How do I install permission-pre-ask with shadcn?

Run `npx shadcn@latest add @bollard/permission-pre-ask`. Sources added: registry/default/permission-pre-ask/permission-pre-ask.tsx, registry/default/permission-pre-ask/permissions.ts. Package requirements: lucide-react.

What props customize Permission Pre-Ask?

Permission Pre-Ask accepts `permission`, `reason`, `title`, `onGranted`, `onDecline`. Configures permissions, notifications, camera behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of permission-pre-ask?

The Permissions API doesn't report every permission in every browser. Re-enable steps are written for major browsers and can drift as they change. Can't re-show the browser prompt once blocked Server requirement: backend verification for permission-pre-ask.

How does Permission Pre-Ask meet accessibility guidelines?

Container uses role=status; the blocked panel is a labelled region. Icons are aria-hidden. Allow and Not now are buttons. Minimizes errors: user blocked notifications, camera permission denied.

Which components pair with Permission Pre-Ask?