{"id":42102131,"url":"https://github.com/Cap-go/capacitor-nfc","last_synced_at":"2026-02-05T13:00:55.822Z","repository":{"id":320981112,"uuid":"1083985012","full_name":"Cap-go/capacitor-nfc","owner":"Cap-go","description":"Capacitor plugin allows you to read and write NFC tags. You can also beam to, and receive from, other NFC enabled devices.","archived":false,"fork":false,"pushed_at":"2026-01-31T23:02:48.000Z","size":588,"stargazers_count":10,"open_issues_count":5,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-01T10:57:25.822Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cap-go.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"Cap-go","patreon":null,"open_collective":"capgo","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2025-10-27T03:47:25.000Z","updated_at":"2026-01-31T23:02:51.000Z","dependencies_parsed_at":"2025-10-30T22:17:13.150Z","dependency_job_id":null,"html_url":"https://github.com/Cap-go/capacitor-nfc","commit_stats":null,"previous_names":["cap-go/capacitor-nfc"],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/Cap-go/capacitor-nfc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-nfc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-nfc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-nfc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-nfc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cap-go","download_url":"https://codeload.github.com/Cap-go/capacitor-nfc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-nfc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29122350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T10:47:47.471Z","status":"ssl_error","status_checked_at":"2026-02-05T10:45:08.119Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-26T13:00:21.333Z","updated_at":"2026-02-05T13:00:55.751Z","avatar_url":"https://github.com/Cap-go.png","language":"Java","funding_links":["https://github.com/sponsors/Cap-go","https://opencollective.com/capgo"],"categories":["Capgo Capacitor Plugins","[Capgo plugins](https://capgo.app/)"],"sub_categories":["Communication \u0026 Messaging"],"readme":"# @capgo/capacitor-nfc\n \u003ca href=\"https://capgo.app/\"\u003e\u003cimg src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/\u003e\u003c/a\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch2\u003e\u003ca href=\"https://capgo.app/?ref=plugin_nfc\"\u003e ➡️ Get Instant updates for your App with Capgo\u003c/a\u003e\u003c/h2\u003e\n  \u003ch2\u003e\u003ca href=\"https://capgo.app/consulting/?ref=plugin_nfc\"\u003e Missing a feature? We’ll build the plugin for you 💪\u003c/a\u003e\u003c/h2\u003e\n\u003c/div\u003e\n\nNative NFC tag detection, reading, and writing for Capacitor apps on iOS and Android.\n\nModern Capacitor port of the battle-tested [phonegap-nfc](https://github.com/chariotsolutions/phonegap-nfc) plugin, aligned with Capgo conventions and tooling.\n\n## Supported Tag Types\n\n- **Standard NFC Forum Tags** (Type 1-4)\n- **MIFARE Ultralight** - Full support for reading NDEF data from MIFARE Ultralight tags, including EV1 and NTAG variants. The plugin automatically detects MIFARE Ultralight cards and extracts NDEF messages in addition to standard NFC tags.\n\n## Documentation\n\nThe most complete documentation will live on the Capgo docs portal. Until then, explore the TypeScript definitions (`src/definitions.ts`) and run the included example app for a tour of the API.\n\n## Compatibility\n\n| Plugin version | Capacitor compatibility | Maintained |\n| -------------- | ----------------------- | ---------- |\n| v8.\\*.\\*       | v8.\\*.\\*                | ✅          |\n| v7.\\*.\\*       | v7.\\*.\\*                | On demand   |\n| v6.\\*.\\*       | v6.\\*.\\*                | ❌          |\n| v5.\\*.\\*       | v5.\\*.\\*                | ❌          |\n\n\u003e **Note:** The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.\n\n## Install\n\n```bash\nnpm install @capgo/capacitor-nfc\nnpx cap sync\n```\n\nRemember to add the required platform configuration:\n\n- **Android:** ensure your `AndroidManifest.xml` declares the `android.permission.NFC` permission.\n- **iOS:** add `NFCReaderUsageDescription` to your app `Info.plist` to explain why NFC access is needed.\n\n## Usage\n\n```ts\nimport { CapacitorNfc } from '@capgo/capacitor-nfc';\n\nawait CapacitorNfc.startScanning({\n  invalidateAfterFirstRead: false, // keep the session open so we can write later\n  alertMessage: 'Hold a tag near the top of your device.',\n});\n\nconst listener = await CapacitorNfc.addListener('nfcEvent', (event) =\u003e {\n  console.info('Tag type:', event.type);\n  console.info('First record:', event.tag?.ndefMessage?.[0]);\n});\n\n// Later, write a simple text record back to the tag\nconst encoder = new TextEncoder();\nconst langBytes = Array.from(encoder.encode('en'));\nconst textBytes = Array.from(encoder.encode('Hello Capgo'));\nconst payload = [langBytes.length \u0026 0x3f, ...langBytes, ...textBytes];\n\nawait CapacitorNfc.write({\n  allowFormat: true,\n  records: [\n    {\n      tnf: 0x01,\n      type: [0x54], // 'T'\n      id: [],\n      payload,\n    },\n  ],\n});\n\nawait listener.remove();\nawait CapacitorNfc.stopScanning();\n```\n\n## API\n\n\u003cdocgen-index\u003e\n\n* [`startScanning(...)`](#startscanning)\n* [`stopScanning()`](#stopscanning)\n* [`write(...)`](#write)\n* [`erase()`](#erase)\n* [`makeReadOnly()`](#makereadonly)\n* [`share(...)`](#share)\n* [`unshare()`](#unshare)\n* [`getStatus()`](#getstatus)\n* [`showSettings()`](#showsettings)\n* [`getPluginVersion()`](#getpluginversion)\n* [`addListener('nfcEvent', ...)`](#addlistenernfcevent-)\n* [`addListener('tagDiscovered' | 'ndefDiscovered' | 'ndefMimeDiscovered' | 'ndefFormatableDiscovered', ...)`](#addlistenertagdiscovered--ndefdiscovered--ndefmimediscovered--ndefformatablediscovered-)\n* [`addListener('nfcStateChange', ...)`](#addlistenernfcstatechange-)\n* [Interfaces](#interfaces)\n* [Type Aliases](#type-aliases)\n\n\u003c/docgen-index\u003e\n\n\u003cdocgen-api\u003e\n\u003c!--Update the source file JSDoc comments and rerun docgen to update the docs below--\u003e\n\nPublic API surface for the Capacitor NFC plugin.\n\nThe interface intentionally mirrors the behaviour of the reference PhoneGap\nimplementation to ease migration while embracing idiomatic Capacitor APIs.\n\n### startScanning(...)\n\n```typescript\nstartScanning(options?: StartScanningOptions | undefined) =\u003e Promise\u003cvoid\u003e\n```\n\nStarts listening for NFC tags.\n\n| Param         | Type                                                                  |\n| ------------- | --------------------------------------------------------------------- |\n| **`options`** | \u003ccode\u003e\u003ca href=\"#startscanningoptions\"\u003eStartScanningOptions\u003c/a\u003e\u003c/code\u003e |\n\n--------------------\n\n\n### stopScanning()\n\n```typescript\nstopScanning() =\u003e Promise\u003cvoid\u003e\n```\n\nStops the ongoing NFC scanning session.\n\n--------------------\n\n\n### write(...)\n\n```typescript\nwrite(options: WriteTagOptions) =\u003e Promise\u003cvoid\u003e\n```\n\nWrites the provided NDEF records to the last discovered tag.\n\n| Param         | Type                                                        |\n| ------------- | ----------------------------------------------------------- |\n| **`options`** | \u003ccode\u003e\u003ca href=\"#writetagoptions\"\u003eWriteTagOptions\u003c/a\u003e\u003c/code\u003e |\n\n--------------------\n\n\n### erase()\n\n```typescript\nerase() =\u003e Promise\u003cvoid\u003e\n```\n\nAttempts to erase the last discovered tag by writing an empty NDEF message.\n\n--------------------\n\n\n### makeReadOnly()\n\n```typescript\nmakeReadOnly() =\u003e Promise\u003cvoid\u003e\n```\n\nAttempts to make the last discovered tag read-only.\n\n--------------------\n\n\n### share(...)\n\n```typescript\nshare(options: ShareTagOptions) =\u003e Promise\u003cvoid\u003e\n```\n\nShares an NDEF message with another device via peer-to-peer (Android only).\n\n| Param         | Type                                                        |\n| ------------- | ----------------------------------------------------------- |\n| **`options`** | \u003ccode\u003e\u003ca href=\"#sharetagoptions\"\u003eShareTagOptions\u003c/a\u003e\u003c/code\u003e |\n\n--------------------\n\n\n### unshare()\n\n```typescript\nunshare() =\u003e Promise\u003cvoid\u003e\n```\n\nStops sharing previously provided NDEF message (Android only).\n\n--------------------\n\n\n### getStatus()\n\n```typescript\ngetStatus() =\u003e Promise\u003c{ status: NfcStatus; }\u003e\n```\n\nReturns the current NFC adapter status.\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;{ status: \u003ca href=\"#nfcstatus\"\u003eNfcStatus\u003c/a\u003e; }\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### showSettings()\n\n```typescript\nshowSettings() =\u003e Promise\u003cvoid\u003e\n```\n\nOpens the system settings page where the user can enable NFC.\n\n--------------------\n\n\n### getPluginVersion()\n\n```typescript\ngetPluginVersion() =\u003e Promise\u003c{ version: string; }\u003e\n```\n\nReturns the version string baked into the native plugin.\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;{ version: string; }\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### addListener('nfcEvent', ...)\n\n```typescript\naddListener(eventName: 'nfcEvent', listenerFunc: (event: NfcEvent) =\u003e void) =\u003e Promise\u003cPluginListenerHandle\u003e\n```\n\n| Param              | Type                                                              |\n| ------------------ | ----------------------------------------------------------------- |\n| **`eventName`**    | \u003ccode\u003e'nfcEvent'\u003c/code\u003e                                           |\n| **`listenerFunc`** | \u003ccode\u003e(event: \u003ca href=\"#nfcevent\"\u003eNfcEvent\u003c/a\u003e) =\u0026gt; void\u003c/code\u003e |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#pluginlistenerhandle\"\u003ePluginListenerHandle\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### addListener('tagDiscovered' | 'ndefDiscovered' | 'ndefMimeDiscovered' | 'ndefFormatableDiscovered', ...)\n\n```typescript\naddListener(eventName: 'tagDiscovered' | 'ndefDiscovered' | 'ndefMimeDiscovered' | 'ndefFormatableDiscovered', listenerFunc: (event: NfcEvent) =\u003e void) =\u003e Promise\u003cPluginListenerHandle\u003e\n```\n\n| Param              | Type                                                                                                   |\n| ------------------ | ------------------------------------------------------------------------------------------------------ |\n| **`eventName`**    | \u003ccode\u003e'tagDiscovered' \\| 'ndefDiscovered' \\| 'ndefMimeDiscovered' \\| 'ndefFormatableDiscovered'\u003c/code\u003e |\n| **`listenerFunc`** | \u003ccode\u003e(event: \u003ca href=\"#nfcevent\"\u003eNfcEvent\u003c/a\u003e) =\u0026gt; void\u003c/code\u003e                                      |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#pluginlistenerhandle\"\u003ePluginListenerHandle\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### addListener('nfcStateChange', ...)\n\n```typescript\naddListener(eventName: 'nfcStateChange', listenerFunc: (event: NfcStateChangeEvent) =\u003e void) =\u003e Promise\u003cPluginListenerHandle\u003e\n```\n\n| Param              | Type                                                                                    |\n| ------------------ | --------------------------------------------------------------------------------------- |\n| **`eventName`**    | \u003ccode\u003e'nfcStateChange'\u003c/code\u003e                                                           |\n| **`listenerFunc`** | \u003ccode\u003e(event: \u003ca href=\"#nfcstatechangeevent\"\u003eNfcStateChangeEvent\u003c/a\u003e) =\u0026gt; void\u003c/code\u003e |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#pluginlistenerhandle\"\u003ePluginListenerHandle\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### Interfaces\n\n\n#### StartScanningOptions\n\nOptions controlling the behaviour of {@link CapacitorNfcPlugin.startScanning}.\n\n| Prop                           | Type                 | Description                                                                                                                    |\n| ------------------------------ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------ |\n| **`invalidateAfterFirstRead`** | \u003ccode\u003eboolean\u003c/code\u003e | iOS-only: closes the NFC session automatically after the first successful tag read. Defaults to `true`.                        |\n| **`alertMessage`**             | \u003ccode\u003estring\u003c/code\u003e  | iOS-only: custom message displayed in the NFC system sheet while scanning.                                                     |\n| **`androidReaderModeFlags`**   | \u003ccode\u003enumber\u003c/code\u003e  | Android-only: raw flags passed to `NfcAdapter.enableReaderMode`. Defaults to enabling all tag types with skipping NDEF checks. |\n\n\n#### WriteTagOptions\n\nOptions used when writing an NDEF message on the current tag.\n\n| Prop              | Type                      | Description                                                                                          |\n| ----------------- | ------------------------- | ---------------------------------------------------------------------------------------------------- |\n| **`records`**     | \u003ccode\u003eNdefRecord[]\u003c/code\u003e | Array of records that compose the NDEF message to be written.                                        |\n| **`allowFormat`** | \u003ccode\u003eboolean\u003c/code\u003e      | When `true`, the plugin attempts to format NDEF-formattable tags before writing. Defaults to `true`. |\n\n\n#### NdefRecord\n\nJSON structure representing a single NDEF record.\n\nMirrors the data format returned by the legacy Cordova implementation and\nuses integer arrays instead of strings to preserve the original payload\nbytes.\n\n| Prop          | Type                  | Description                                             |\n| ------------- | --------------------- | ------------------------------------------------------- |\n| **`tnf`**     | \u003ccode\u003enumber\u003c/code\u003e   | Type Name Format identifier.                            |\n| **`type`**    | \u003ccode\u003enumber[]\u003c/code\u003e | Type field expressed as an array of byte values.        |\n| **`id`**      | \u003ccode\u003enumber[]\u003c/code\u003e | Record identifier expressed as an array of byte values. |\n| **`payload`** | \u003ccode\u003enumber[]\u003c/code\u003e | Raw payload expressed as an array of byte values.       |\n\n\n#### ShareTagOptions\n\nOptions used when sharing an NDEF message with another device using Android Beam / P2P mode.\n\n| Prop          | Type                      |\n| ------------- | ------------------------- |\n| **`records`** | \u003ccode\u003eNdefRecord[]\u003c/code\u003e |\n\n\n#### PluginListenerHandle\n\n| Prop         | Type                                      |\n| ------------ | ----------------------------------------- |\n| **`remove`** | \u003ccode\u003e() =\u0026gt; Promise\u0026lt;void\u0026gt;\u003c/code\u003e |\n\n\n#### NfcEvent\n\nGeneric NFC discovery event dispatched by the plugin.\n\n| Prop       | Type                                                  |\n| ---------- | ----------------------------------------------------- |\n| **`type`** | \u003ccode\u003e\u003ca href=\"#nfceventtype\"\u003eNfcEventType\u003c/a\u003e\u003c/code\u003e |\n| **`tag`**  | \u003ccode\u003e\u003ca href=\"#nfctag\"\u003eNfcTag\u003c/a\u003e\u003c/code\u003e             |\n\n\n#### NfcTag\n\nRepresentation of the full tag information returned by the native layers.\n\nSupports standard NFC Forum tags as well as MIFARE Ultralight cards (including\nEV1 and NTAG variants). NDEF data is automatically extracted from MIFARE Ultralight\ntags when available.\n\n| Prop                  | Type                              | Description                                                                            |\n| --------------------- | --------------------------------- | -------------------------------------------------------------------------------------- |\n| **`id`**              | \u003ccode\u003enumber[]\u003c/code\u003e             | Raw identifier bytes for the tag.                                                      |\n| **`techTypes`**       | \u003ccode\u003estring[]\u003c/code\u003e             | List of Android tech strings (e.g. `android.nfc.tech.Ndef`).                           |\n| **`type`**            | \u003ccode\u003estring \\| null\u003c/code\u003e       | Human readable tag type when available (e.g. `NFC Forum Type 2`, `MIFARE Ultralight`). |\n| **`maxSize`**         | \u003ccode\u003enumber \\| null\u003c/code\u003e       | Maximum writable size in bytes for tags that expose NDEF information.                  |\n| **`isWritable`**      | \u003ccode\u003eboolean \\| null\u003c/code\u003e      | Indicates whether the tag can be written to.                                           |\n| **`canMakeReadOnly`** | \u003ccode\u003eboolean \\| null\u003c/code\u003e      | Indicates whether the tag can be permanently locked.                                   |\n| **`ndefMessage`**     | \u003ccode\u003eNdefRecord[] \\| null\u003c/code\u003e | Array of NDEF records discovered on the tag.                                           |\n\n\n#### NfcStateChangeEvent\n\nEvent emitted whenever the NFC adapter availability changes.\n\n| Prop          | Type                                            |\n| ------------- | ----------------------------------------------- |\n| **`status`**  | \u003ccode\u003e\u003ca href=\"#nfcstatus\"\u003eNfcStatus\u003c/a\u003e\u003c/code\u003e |\n| **`enabled`** | \u003ccode\u003eboolean\u003c/code\u003e                            |\n\n\n### Type Aliases\n\n\n#### NfcStatus\n\nPossible NFC adapter states returned by {@link CapacitorNfcPlugin.getStatus}.\n\nMatches the constants provided by the original PhoneGap NFC plugin for\ncompatibility with existing applications.\n\n\u003ccode\u003e'NFC_OK' | 'NO_NFC' | 'NFC_DISABLED' | 'NDEF_PUSH_DISABLED'\u003c/code\u003e\n\n\n#### NfcEventType\n\nEvent type describing the kind of NFC discovery that happened.\n\n- `tag`: A generic NFC tag (no NDEF payload).\n- `ndef`: A tag exposing an NDEF payload.\n- `ndef-mime`: An NDEF tag that matched one of the MIME type filters.\n- `ndef-formatable`: A tag that can be formatted to NDEF.\n\n\u003ccode\u003e'tag' | 'ndef' | 'ndef-mime' | 'ndef-formatable'\u003c/code\u003e\n\n\u003c/docgen-api\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCap-go%2Fcapacitor-nfc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCap-go%2Fcapacitor-nfc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCap-go%2Fcapacitor-nfc/lists"}