Skip to main content
Back to plugins
@capgo/capacitor-nfc
Tutorial
by github.com/Cap-go

NFC

Native NFC tag discovery, reading and writing for Capacitor apps on iOS and Android

Guide

Tutorial on NFC

Using @capgo/capacitor-nfc

Public API surface for the Capacitor NFC plugin.

Install

bun add @capgo/capacitor-nfc
bunx cap sync

What This Plugin Exposes

  • startScanning - Starts listening for NFC tags.
  • stopScanning - Stops the ongoing NFC scanning session.
  • write - Writes the provided NDEF records to the last discovered tag.
  • erase - Attempts to erase the last discovered tag by writing an empty NDEF message.

Example Usage

startScanning

Starts listening for NFC tags.

import { CapacitorNfc } from '@capgo/capacitor-nfc';

await CapacitorNfc.startScanning();

stopScanning

Stops the ongoing NFC scanning session.

import { CapacitorNfc } from '@capgo/capacitor-nfc';

await CapacitorNfc.stopScanning();

write

Writes the provided NDEF records to the last discovered tag.

import { CapacitorNfc } from '@capgo/capacitor-nfc';

await CapacitorNfc.write({} as WriteTagOptions);

erase

Attempts to erase the last discovered tag by writing an empty NDEF message.

import { CapacitorNfc } from '@capgo/capacitor-nfc';

await CapacitorNfc.erase();

Full Reference