To test Web NFC as of the date of this guide (August 2021), the author used a Samsung S21 Ultra phone running Android 11 and Chrome 93.0.4577.15 Beta. If you wish to replicate this using an iDevice and/or another browser, see the compatibility tests link on the Reference page.

projects_Untitled.jpg
Sample JavaScript code to write text to an NFC card

JavaScript

Web NFC can be implemented in a web browser via a scripting language, which for the web is most often JavaScript. Sample code snippets can be found in the article here and in the specification document.

Test Web Page

Sven Haiges at SAP Customer Experience Labs has developed a test web page for reading and writing tags using NDEF. For testing Web NFC, that web page will be used with the tags gathered from the Parts List.

In the video below, The Adafruit Adafruit ST25DV16K I2C RFID EEPROM Breakout is read showing the URL of the product page (https://www.adafruit.com/product/4701). After that, an NDEF card tag is read, then the text "Hello Office of the CTO!" is written to the tag by the test page and then read back.

Every time a tag is read, there is a faint sound and haptic feedback to know the tag has been read.

If you get an error that NDEF is not available, ensure that NFC is enabled in your operating system settings and that you are using the latest browser.

Have fun experimenting with reading and writing to NDEF NFC tags with Web NFC. Of you come up with some projects using Web NFC, tag @Adafruit on social media or at https://forums.adafruit.com/.

This guide was first published on Aug 03, 2021. It was last updated on Aug 03, 2021.

This page (Use) was last updated on Aug 03, 2021.

Text editor powered by tinymce.