npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-keycard

v1.0.3

Published

A React Native library to interact with Keycard using NFC connection

Downloads

313

Readme

React Native Keycard SDK

React Native New Architecture library to interact with Keycard using NFC connection. At the moment, only low-level API (Native Android & iOS NFC communication) is implemented. High-level API is coming soon.

Installation and setup

npm install https://github.com/choppu/react-native-keycard.git

‼️ For react-native-keycard & keycard-sdk libraries proper functioning install react-native-get-random-values.

React Native Keycard and React Native App without framework

Android setup

Provide NFC & Camera permissions by updating android/app/src/main/AndroidManifest.xml to :

<uses-permission android:name="android.permission.NFC"/>
<uses-feature android:name="android.hardware.nfc.hce" android:required="true" />

iOS setup

  1. Insert the following lines inside dict block of ios/<ProjectDir>/Info.plist to configure NFC permissions:
<key>NFCReaderUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to NFC to interact with Keycard.</string>

...

<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
    <string>A00000080400010101</string>
    <string>A00000080400010301</string>
    <string>A000000151000000</string>
</array>
  1. Open your project in Xcode, go to Signing & Capabilities and add Near Field Communication Tag Reading capability.

  2. In terminal:

cd ios
pod install

React Native Keycard and React Native App with Expo

  1. Update app.json file to configure NFC permissions:

Android

"android": {
     ...
     "permissions": ["android.permission.NFC"],
     ...
}

iOS

...
"ios": {
     ....
     "entitlements": {
       "com.apple.developer.nfc.readersession.formats": ["TAG"]
     },
     "infoPlist": {
       "NFCReaderUsageDescription": "This app needs access to NFC to interact with Keycard.",
       "com.apple.developer.nfc.readersession.iso7816.select-identifiers": [
         "A00000080400010101",
         "A00000080400010301",
         "A000000151000000"
       ]
     }
   },
  1. Write a custom config plugin for react-native-keycard to make custom native changes.

    In project directory, create a expo-custom directory and add app.plugin.ts.

    Example app.plugin.ts

import { ExpoConfig } from '@expo/config-types';
import { ConfigPlugin, withAndroidManifest } from 'expo/config-plugins';


// Set  the android.hardware.nfc.hce feature required to true in AndroidManifest.xml
const withAndroidFeatures: ConfigPlugin = config => {
return withAndroidManifest(config, async (config: any) => {
    const existingFeature = config.modResults.manifest['uses-feature']?.find((p: any) => p['$'] && p['$']['android:name'] === 'android.hardware.nfc.hce');

    if (!existingFeature) {
      config.modResults.manifest['uses-feature'] =
        config.modResults.manifest['uses-feature'] ?? [];
      config.modResults.manifest['uses-feature'].push({
        $: {
          'android:name': 'android.hardware.nfc.hce',
          'android:required': 'true'
        },
      });
    }

    return config;
  });
}

//configuration function
const withKeycardSDK = (config: ExpoConfig) => {
config = withAndroidFeatures(config);
return config;
};

export default withKeycardSDK;
  1. Create app.config.ts for dynamic plugins configuration in app.json.

    Example code to dynamically update plugins block adding app.plugin:

import "tsx/cjs";
import withKeycardSDK from './expo-custom/app.plugin';

export default ({ config }) => {
  if (!config.plugins) config.plugins = [];
  config.plugins.push(
    withKeycardSDK,
  );
  return config;
};
  1. Run npx expo prebuild --clean. Learn how to adopt Expo Prebuild in a project that was bootstrapped with React Native CLI here.

API usage

The current version of the library is implementing only the (Android / iOS) Device <-> Keycard NFC communication and event handling, NFCCardChannel creation, low-level APDU send method. For high-level API please use Typescript keycard-sdk, which is meant for development of applications for Keycard. Check keycard-sdk page for more details on installation and usage.

The exposed part of the library is divided in 3 parts.

RNKeycard.Core methods

isNFCSupported

checks if NFC is supported.

Example

import React from 'react';
import RNKeycard from 'react-native-keycard';

const nfcSupported = await RNKeycard.Core.isNFCSupported();
console.log(nfcSupported);

Returns Promise<boolean>.

isNFCEnabled

checks if NFC is enabled.

Example

import React from 'react';
import RNKeycard from 'react-native-keycard';

if (await RNKeycard.Core.isNFCEnabled()) {
  await RNKeycard.Core.startNFC("Tap your card");
  console.log('NFC started');
} else {
  await openNFCSettings();

  ...do something...

}

Returns Promise<boolean>.

openNFCSettings

opens NFC Settings on Android. Unsupported on iOS.

Example

import React from 'react';
import RNKeycard from 'react-native-keycard';

if (await RNKeycard.Core.isNFCEnabled()) {
  await RNKeycard.Core.startNFC("Tap your card");
  console.log('NFC started');
} else {
  await openNFCSettings();

  ...do something...

}

Returns Promise<boolean>.

setNFCMessage

updates the alert message on iOS. Unsupported on Android.

Example

import React from 'react';
import RNKeycard from 'react-native-keycard';

if (await RNKeycard.Core.isNFCEnabled()) {
  await RNKeycard.Core.startNFC("Tap your card");
  await RNKeycard.Core.setNFCMessage("Custom message");

  console.log('NFC started');
} else {
  await openNFCSettings();

  ...do something...

}

Returns Promise<void>.

startNFC

starts NFC.

Parameters

  • message string: a message to show on NFC modal screen.

Example

import React from 'react';
import RNKeycard from 'react-native-keycard';

if (await RNKeycard.Core.isNFCEnabled()) {
  await RNKeycard.Core.startNFC("Tap your card");
  console.log('NFC started');
} else {
  await openNFCSettings();

  ...do something...

}

Returns Promise<boolean>.

stopNFC

stops NFC.

Example

import React from 'react';
import RNKeycard from 'react-native-keycard';

RNKeycard.Core.onKeycardNFCEnabled(async () => {

  ...do something..

  await RNKeycard.Core.stopNFC();
});


if (await RNKeycard.Core.isNFCEnabled()) {
  await RNKeycard.Core.startNFC("Tap your card");
  console.log('NFC started');
}

Returns Promise<boolean>.

isKeycardConnected

checks Keycard connection status.

Example

import React from 'react';
import RNKeycard from 'react-native-keycard';

RNKeycard.Core.onKeycardNFCEnabled(async () => {

  ...do something..

  const keycardConnected = RNKeycard.Core.isKeycardConnected();
  console.log(keycardConnected);
});


if (await RNKeycard.Core.isNFCEnabled()) {
  await RNKeycard.Core.startNFC("Tap your card");
  console.log('NFC started');
}

Returns boolean.

send

sends a Keycard APDU command. Low-level send method.

Parameters

  • apdu hex string: a command to send.

Example

Check RNKeycard.NFCCardChannel send method implementation for usage details.

Returns Promise<{data: string, state: string}>. Data is returned as hex string.

RNKeycard.Core events

  • onKeycardConnected

  • onKeycardDisconnected

  • onKeycardNFCEnabled

  • onKeycardNFCDisabled

  • onNFCUserCancelled

  • onNFCTimeout

RNKeycard.NFCCardChannel methods

RNKeycard.NFCCardChannel is a high-level implementation of NFC Card Channel, which gives an abstraction level to core send function. Implements CardChannel interface of Typescript keycard-sdk.

send

sends a Keycard APDU command. Low-level send method.

Parameters

Returns Promise<APDUResponse>.

isConnected

checks Keycard connection status.

Returns boolean.

RNKeycard.PairingStorage

RNKeycard.PairingStorage is an implementation of CardChannel interface of Typescript keycard-sdk.

RNKeycard.PairingStorage requires react-native-mmkv and react-native-nitro-modules to be installed.

‼️ If low-level API is used, usage of keycard-sdk for full functonality is strongly recommended.

Usage with keycard-sdk KeycardManager class

KeycardManager is a utility class, implemented in Typescript keycard-sdk, which is meant to handle the card's lifycycle. Usage of runOnSecureChannel method of KeycardManager facilitates the handling of card initialization, authentication, pairing and opening of secure channel processes.

For complete usage example check Example project of the library.