Skip to content
Product block

Push Permission Pre-Prompt

The soft ask before the browser dialog you only get one shot at — what will be sent, what will not, and a decline of the same weight as the yes.

222 lineslucide-reactAdded 25 Aug 2026
  • push
  • permission
  • notifications
  • opt-in
  • browser

What's included

  • components/push-permission-prompt.tsx
  • Needs lucide-react

Works with

  • React
  • Next.js
  • Tailwind CSS
  • TypeScript

npx hoverlab add push-permission-prompt

Or over MCP, from your editor's agent — no account needed.

License

Free to read, copy and install, for personal and non-commercial projects. Shipping it in client work or a paid product needs Pro ($79 once). The source lands in your repo and stops being ours — no attribution, nothing to upgrade.

Was this useful?

Start a page with this section — add more, order them, and leave with the page source.

Preview

Want to know when this finishes?

Your build usually takes about nine minutes.

  • A deploy finishes or fails
  • Someone replies to a thread you are in
  • A scheduled export is ready to download

No marketing, no digests, no re-engagement nudges — those go to email, where you can unsubscribe.

This asks your browser next. We will not ask here again.

Rendered live in your current theme — this is the same component whose source is below, not a screenshot of it.

Source

components/push-permission-prompt.tsx
'use client'

/**
 * <PushPermissionPrompt> — the ask before the browser's ask.
 *
 * Notifications had the toast, the inbox and the preferences matrix — the
 * three screens that exist once someone has already said yes. This is the
 * moment they say it, and it is the one with consequences that cannot be
 * undone.
 *
 * WHY A PRE-PROMPT IS NOT A DARK PATTERN
 *
 * `Notification.requestPermission()` can be answered "block" exactly once,
 * and after that the site cannot ask again — not next week, not after
 * shipping the feature that would have made it worth it. Only the user can
 * reverse it, buried in site settings almost nobody opens.
 *
 * So the native dialog is a one-shot with no retry, and firing it on page
 * load, before anyone knows what they would be subscribing to, spends it on
 * a reflex. The soft ask costs nothing when declined: "not now" is
 * recoverable, "block" is not. That is the whole argument, and it is why
 * this pattern is worth having as a block rather than a line of code.
 *
 * WHAT MAKES A SOFT ASK HONEST RATHER THAN MANIPULATIVE
 *
 *   It says what will be sent, specifically, and what will not. "Enable
 *   notifications?" is not a question anyone can answer well.
 *   Declining is a real button of the same weight, not grey text.
 *   It does not reappear on the next page load. One dismissal is an answer.
 *   It is triggered by a moment that earns it — after a build was queued,
 *   an export started, a thread was joined — never on arrival.
 *
 * WHAT IT DOES NOT DO
 *
 * It does not call `requestPermission()` on mount, on scroll, or on any
 * timer. `onEnable` is where the real call goes, and it fires from a click
 * — which is also what Safari requires, and increasingly what Chrome's
 * heuristics expect.
 *
 * The `denied` state is rendered because it will happen and the block is
 * incomplete without it: at that point the only honest thing to show is
 * where the browser setting is, since nothing in the page can reopen it.
 */

import * as React from 'react'
import { Bell, BellOff, Check, X } from 'lucide-react'

export type PushPermission = 'default' | 'granted' | 'denied'

export interface PushPermissionPromptProps {
  heading?: string
  /** What will actually be sent. Be specific or do not ask. */
  willSend?: string[]
  /** What will never be sent. The half that earns the yes. */
  willNotSend?: string
  /** The moment that triggered the ask, named back to them. */
  context?: string
  permission?: PushPermission
  onEnable?: () => void
  onDismiss?: () => void
  className?: string
}

const DEFAULT_WILL_SEND = [
  'A deploy finishes or fails',
  'Someone replies to a thread you are in',
  'A scheduled export is ready to download',
]

export function PushPermissionPrompt({
  heading = 'Want to know when this finishes?',
  willSend = DEFAULT_WILL_SEND,
  willNotSend = 'No marketing, no digests, no re-engagement nudges — those go to email, where you can unsubscribe.',
  context = 'Your build usually takes about nine minutes.',
  permission = 'default',
  onEnable,
  onDismiss,
  className = '',
}: PushPermissionPromptProps) {
  /*
    Per-instance prefix for every id this block emits.

    The literals these replaced were a latent duplicate the moment the
    block appeared twice on one document, and `aria-labelledby` on a
    duplicated id resolves to the first match -- so the second copy was
    labelled by the first copy's heading. Client component, so `useId` is
    the right tool.
  */
  const uid = React.useId()

  const [state, setState] = React.useState<PushPermission>(permission)
  const [dismissed, setDismissed] = React.useState(false)

  if (dismissed) return null

  if (state === 'granted') {
    return (
      <section className={`mx-auto w-full max-w-md px-4 py-16 sm:px-6 ${className}`}>
        <div
          role="status"
          className="flex items-start gap-3 rounded-2xl border border-border bg-card p-4"
        >
          <Check aria-hidden className="mt-0.5 h-5 w-5 shrink-0 text-foreground" />
          <div>
            <p className="text-sm font-medium text-foreground">Notifications are on.</p>
            <p className="mt-1 text-sm text-muted-foreground">
              You can change exactly what gets sent in Settings, and turn them off
              there too.
            </p>
          </div>
        </div>
      </section>
    )
  }

  /*
    Blocked. Nothing in the page can undo this — see the note at the top —
    so the only useful thing left is to say where the switch is.
  */
  if (state === 'denied') {
    return (
      <section className={`mx-auto w-full max-w-md px-4 py-16 sm:px-6 ${className}`}>
        <div className="flex items-start gap-3 rounded-2xl border border-border bg-card p-4">
          <BellOff aria-hidden className="mt-0.5 h-5 w-5 shrink-0 text-muted-foreground" />
          <div>
            <p className="text-sm font-medium text-foreground">
              Your browser is blocking notifications for this site.
            </p>
            <p className="mt-1 text-sm text-muted-foreground">
              We cannot ask again from here — browsers only allow that once. To
              turn them back on, open the padlock in the address bar and set
              Notifications to Allow.
            </p>
          </div>
        </div>
      </section>
    )
  }

  return (
    <section
      aria-labelledby={`${uid}-push-prompt-heading`}
      className={`mx-auto w-full max-w-md px-4 py-16 sm:px-6 ${className}`}
    >
      <div className="rounded-2xl border border-border bg-card p-5 shadow-sm">
        <div className="flex items-start gap-3">
          <span
            aria-hidden
            className="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary"
          >
            <Bell className="h-4.5 w-4.5" />
          </span>
          <div className="min-w-0 flex-1">
            <h2 id={`${uid}-push-prompt-heading`} className="text-sm font-semibold text-foreground">
              {heading}
            </h2>
            {context ? (
              <p className="mt-1 text-sm text-muted-foreground">{context}</p>
            ) : null}
          </div>
          <button
            type="button"
            onClick={() => {
              setDismissed(true)
              onDismiss?.()
            }}
            className="-m-1 rounded p-1 text-muted-foreground transition hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
          >
            <X aria-hidden className="h-4 w-4" />
            <span className="sr-only">Dismiss</span>
          </button>
        </div>

        {/* Specific, or do not ask. */}
        <ul className="mt-4 space-y-1.5 border-t border-border/60 pt-4 text-sm text-muted-foreground">
          {willSend.map((item) => (
            <li key={item} className="flex items-start gap-2">
              <Check aria-hidden className="mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground" />
              {item}
            </li>
          ))}
        </ul>

        <p className="mt-3 text-xs text-muted-foreground">{willNotSend}</p>

        <div className="mt-4 flex gap-2">
          <button
            type="button"
            onClick={() => {
              /*
                The real `Notification.requestPermission()` belongs here, in
                a click handler — never on mount, and never on a timer.
              */
              setState('granted')
              onEnable?.()
            }}
            className="inline-flex h-9 flex-1 items-center justify-center rounded-lg bg-primary px-4 text-sm font-semibold text-primary-foreground transition hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
          >
            Notify me
          </button>
          {/* Same weight as the yes. A grey link here is the tell that a
              soft ask has stopped being a question. */}
          <button
            type="button"
            onClick={() => {
              setDismissed(true)
              onDismiss?.()
            }}
            className="inline-flex h-9 flex-1 items-center justify-center rounded-lg border border-border bg-background px-4 text-sm font-medium text-foreground transition hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
          >
            Not now
          </button>
        </div>

        <p className="mt-3 text-center text-[11px] text-muted-foreground">
          This asks your browser next. We will not ask here again.
        </p>
      </div>
    </section>
  )
}

Before you paste

  • Styling is Tailwind utility classes on semantic tokens (bg-card, text-muted-foreground) — it inherits your theme instead of overriding it.
  • Install: npm i lucide-react
  • Every prop has a default, so it renders standalone before you wire it up.

Where it goes

Drop it at components/push-permission-prompt.tsx and import it where you need the section:

import { PushPermissionPrompt } from '@/components/push-permission-prompt'

Customize

2 of this block’s props are simple enough to drive from here. Change them and the block below re-renders — it is the same component whose source is above, not a mock of it. Everything else it accepts is in the table underneath.

Props

Read out of the component’s own type and signature, so this cannot drift from the source below. Every prop has a default — the component renders standalone before you pass it anything.

PropTypeDefault
headingstring'Want to know when this finishes?'
willSendWhat will actually be sent. Be specific or do not ask.string[]DEFAULT_WILL_SEND
willNotSendWhat will never be sent. The half that earns the yes.string—
contextThe moment that triggered the ask, named back to them.string'Your build usually takes about nine minutes.'
permissionPushPermission'default'
onEnable() => void—
onDismiss() => void—
classNamestring''

Not using React?

The same block rendered once to markup, wrapped as a file your framework compiles. Tailwind classes are framework-agnostic, so the design transfers intact — the behaviour does not.

This block is interactive. The markup below is its initial state with the event handlers stripped — you will need to re-wire the behaviour in your framework.

push-permission-prompt.html
<!--
  Push Permission Pre-Prompt — markup from the Hoverlab catalog.

  This is the block rendered once to HTML and wrapped as a component
  file. It is not a port of the React source: the Tailwind classes carry
  the design, which is the part that took the work, and they are the same
  in every framework.

  This block is interactive in React and the handlers are NOT here.
  Buttons, toggles and menus render in their initial state and do
  nothing until you wire them up.
-->
<section aria-labelledby="_R_0_-push-prompt-heading" class="mx-auto w-full max-w-md px-4 py-16 sm:px-6 ">
  <div class="rounded-2xl border border-border bg-card p-5 shadow-sm">
    <div class="flex items-start gap-3">
      <span aria-hidden="true" class="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary">
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-bell h-4.5 w-4.5" aria-hidden="true">
          <path d="M10.268 21a2 2 0 0 0 3.464 0"></path>
          <path d="M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"></path>
        </svg>
      </span>
      <div class="min-w-0 flex-1">
        <h2 id="_R_0_-push-prompt-heading" class="text-sm font-semibold text-foreground">Want to know when this finishes?</h2>
        <p class="mt-1 text-sm text-muted-foreground">Your build usually takes about nine minutes.</p>
      </div>
      <button type="button" class="-m-1 rounded p-1 text-muted-foreground transition hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background">
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x h-4 w-4" aria-hidden="true">
          <path d="M18 6 6 18"></path>
          <path d="m6 6 12 12"></path>
        </svg>
        <span class="sr-only">Dismiss</span>
      </button>
    </div>
    <ul class="mt-4 space-y-1.5 border-t border-border/60 pt-4 text-sm text-muted-foreground">
      <li class="flex items-start gap-2"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground" aria-hidden="true"><path d="M20 6 9 17l-5-5"></path></svg>A deploy finishes or fails</li>
      <li class="flex items-start gap-2"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground" aria-hidden="true"><path d="M20 6 9 17l-5-5"></path></svg>Someone replies to a thread you are in</li>
      <li class="flex items-start gap-2"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground" aria-hidden="true"><path d="M20 6 9 17l-5-5"></path></svg>A scheduled export is ready to download</li>
    </ul>
    <p class="mt-3 text-xs text-muted-foreground">No marketing, no digests, no re-engagement nudges — those go to email, where you can unsubscribe.</p>
    <div class="mt-4 flex gap-2">
      <button type="button" class="inline-flex h-9 flex-1 items-center justify-center rounded-lg bg-primary px-4 text-sm font-semibold text-primary-foreground transition hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background">Notify me</button>
      <button type="button" class="inline-flex h-9 flex-1 items-center justify-center rounded-lg border border-border bg-background px-4 text-sm font-medium text-foreground transition hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background">Not now</button>
    </div>
    <p class="mt-3 text-center text-[11px] text-muted-foreground">This asks your browser next. We will not ask here again.</p>
  </div>
</section>
  • This is rendered HTML, not a translation of the React source. The Tailwind classes carry the design and work in any framework.
  • It is one frame: the component in its initial state, with no props applied beyond the defaults.
  • This block is interactive in React — toggles, menus or form state. None of that survives here; the markup is the closed/default state and the handlers are gone. Re-wire them in your own framework.
  • Requires Tailwind, and the design tokens the classes reference (bg-card, text-muted-foreground, and so on). The template ZIPs ship a globals.css that defines them.

What each framework gets across the whole catalog — effects convert properly; this rung is markup.

For AI

The component, its props, the design tokens it expects and the command that installs it — as one prompt. Paste it into Claude, Cursor, v0 or ChatGPT and what they build around it will match the rest of the catalog instead of inventing its own system.

See the prompt

Used in these pages

Want the whole screen instead of this one section? Open a page and copy it entire.

6 more blocks in Notifications

All of them free to read, copy and install — no account, no locked tiles, no watermarked preview. The whole catalog is open, and so are the API and the CLI.

Browse Notifications

Shipping one commercially

Copying the code is free. Putting it in client work or a paid product is what Pro is for — the licence, not the access.

  • A commercial licence for everything in the catalog
  • Unlimited bundle exports, in Vue, Svelte and Tailwind
  • One payment — no subscription, nothing to renew
Pro — $79 once

More Notifications blocks

View category
Open the full page for this block

Toast Notification Stack

A corner stack whose live region is mounted before any message exists, errors announce assertively, and the auto-dismiss timer pauses on hover and on focus.

Notifications171 lines1 dep
Open the full page for this block

Notification Inbox Panel

The bell panel: filterable list with read state, the unread count in the accessible name rather than only in a badge, and machine-readable timestamps beside the human ones.

Notifications255 lines1 dep
Open the full page for this block

Notification Preferences Matrix

Per-event, per-channel switches as a real table, with required notifications locked and explained, and column headers that toggle a whole channel and report a mixed state honestly.

Notifications284 lines1 dep
Open the full page for this block

Notification Digest

A day's notifications collapsed into one digest, grouped by what they are rather than when they arrived.

Notifications152 linesNo deps
Open the full page for this block

Digest Schedule Form

The control that turns notification volume down instead of off, which is the choice most people actually want.

Notifications175 linesNo deps
Open the full page for this block

Notification Channel List

Which channel carries which event, so the loud ones can be moved rather than muted entirely.

Notifications142 linesNo deps