Skip to main content
useTap drives an in-page scan for customers already on your page. scan() runs the Web NFC source and verifies whatever it reads, adopting the result as the provider’s active session - so useSession updates in place. It is a progressive enhancement over the landing redirect EndstateProvider already handles, not a replacement. Web NFC needs a user gesture, so call scan() from a control the customer presses - never at mount - so the browser’s permission prompt can appear. permission reports the origin’s Web NFC state so you can decide whether to offer the scan at all.

Example

Returns

() => Promise<void>
Runs an in-page Web NFC scan and verifies the tap, updating the active session. Call it inside a user gesture. It captures only the Web NFC source, so it never re-reads the landing redirect.
"idle" | "scanning" | "error"
"idle" at rest, "scanning" while a scan runs, "error" when it fails. Verification progress itself surfaces through useSession().status.
Error | null
The failure from the last scan, or null. A scan can reject even from "granted" or "prompt" - a dismissed prompt, an empty-tag read - as a typed WebNfcError; branch on its reason.
WebNfcPermissionState
The origin’s Web NFC permission: "granted", "prompt", "denied", or "unsupported". Offer the scan on "granted" or "prompt", route the customer to site settings on "denied", and fall back to the redirect on "unsupported". See webNfcPermissionState.

See also

useSession

The session a scan updates in place.

Tap capture

The source priority model and the user-gesture rule.

webNfcPermissionState

Read the origin’s scan permission.

WebNfcError

The typed failures a scan rejects with.