Read and write NFC tag data
Learn how to scan and write data to NFC tags.
Retool Mobile can read data from NFC tags and supports writing data using NDEF (NFC Data Exchange Format) records.
Read data using the NFC Reader mobile component
The NFC Reader mobile component uses a mobile device's native NFC reader interface without any additional configuration required. When a user presses the button, the native NFC reader appears and scans the NFC tag. The scanned data is then available using the component's value
property.
This method for reading NFC data requires no additional configuration but often results in the native interface obscuring the app.
Read and write data using the NFC resource
You can use the NFC (Near-field communication) resource for mobile apps to read and write NFC tag data. Unlike the NFC Reader mobile component, NFC resource queries don't use the native NFC reader interface. When the query is triggered, the NFC resource reads or writes NFC data seamlessly, which is better suited for frequent use of NFC tags.
1. Create a resource query
First, create a query that uses the NFC resource.
- Click to open the Code tab.
- Click + to add a query.
- Select Resource query.
- Select the NFC resource.
2. Select the NFC method
- Read NFC data
- Write NFC data
Select the Read action to read NFC data. No additional configuration is required.
Read data using an NFC resource query.
Select the Write action to write data to NFC tags. This is stored as a NDEF TEXT record.
Write data using an NFC resource query.