NDEFWriter.write()

Draft
This page is not complete.

Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The write() method of NDEFWriter interface writes a specified message to a compatiable NFC tag.

Syntax

var sessionPromise = NDEFWriter.write(message, options);

Parameters

message
The message to be written, either DOMString or BufferSource or NDEFMessageInit.
options Optional
  • ignoreRead -- Boolean specifying whether or not to skip reading for the activated reader objects. Will be ignored if overwrite is false.
  • overwrite -- Boolean specifying whether or not existing record should be overwritten, if such exists.
  • signal -- optional AbortSignal that allows to cancell this write operation.

Return value

A Promise that resolves with undefined when and if the message transfer is successfully completed.

Exceptions

This method doesn't throw true exceptions; instead, it rejects the returned promise, passing into it a DOMException whose name is one of the following:

AbortError
The write operation was aborted with AbortSignal passed in options.
NotAllowedError
The permission for this operation was rejected or overwrite is false and there are already records on the tag.
NotSupportedError
There is no NFC adapter compatible with Web NFC, or the available NFC adapter does not support pushing messages, or connection can not be established.
NotReadableError
The UA is not allowed to access underlying NFC adapter (e.g., due to user preference).
NetworkError
Transfer failed after it already started (e.g., the tag was removed from the reader).

Specifications

Specification Status Comment
Web NFC, write() Draft Initial definition.

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
write
Experimental
Chrome No support NoEdge No support NoFirefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support No

Legend

No support
No support
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.