Skip to main content
Web NFC permission is granted per site, and a denial never re-prompts on its own. Call this before offering a scan so the interface can branch: offer the scan when a prompt is still possible, and route the customer to the browser’s site settings once scanning is blocked.

Example

Parameters

() => WebNfcWindow | undefined
Test seam that supplies the window the check reads NDEFReader and the permissions API from. Defaults to the page’s own window. Leave it unset in product code.

Returns

A Promise<WebNfcPermissionState>, one of:
WebNfcPermissionState
Scanning is allowed for this origin. A scan started inside a user gesture proceeds without a prompt.
WebNfcPermissionState
Scanning has not been decided. A scan started inside a user gesture asks the customer. Also returned as a safe default when the reader exists but the permission is not queryable.
WebNfcPermissionState
Scanning is blocked for this origin. Only the browser’s site settings can re-enable it, so present that path rather than retrying the scan.
WebNfcPermissionState
The device exposes no NDEFReader. Web NFC is not available here; rely on the redirect source.
This reports the origin’s permission, not the outcome of a scan. A scan can still fail from "granted" or "prompt" - for example a dismissed prompt or an empty-tag read. Handle those through WebNfcError.reason.

See also