@doko/react-native-yubikit
v0.0.2
Published
Yubikit bindings for React Native
Readme
react-native-yubikit
A React Native TurboModule wrapper around Yubico's native YubiKit Android and YubiKit iOS SDKs, for talking to YubiKey hardware over USB and NFC.
📖 Full documentation: doko.aniviet.com/oss/react-native-yubikey
The docs site covers requirements, installation (including the iOS Podfile override you need), usage examples for every module, security notes, advanced patterns, and troubleshooting. This README is deliberately short - start there for anything beyond a quick look.
Features
- 🔌 USB + NFC discovery - attach/detach events via a single
YubiKeyEventstream - 🧩 8 native modules, exposed as namespaces:
Core,Support,Management,Oath,Piv,OpenPgp,YubiOtp,Fido - 🪝
YubiKeyProvider+useYubiKey()- drop-in device discovery/selection state, no boilerplate required - 🔐 PIV - PIN/PUK, slot metadata, certificates, key generation, raw sign/decrypt
- 🔑 FIDO2/WebAuthn - authenticator info, registration, authentication
- ⏱️ OATH - TOTP/HOTP credential management and code calculation
- 🆕 New Architecture only - built as Fabric/TurboModules with Codegen, no old-bridge fallback
Platform support
Android has full parity across every module. iOS is missing OpenPGP entirely, YubiOTP slot programming, and FIDO2 resident-credential management - these gaps come from the underlying YubiKit iOS SDK itself, not from this wrapper. See the full platform support table on the docs site for the exact per-method breakdown.
| Module | Android | iOS | | -------------- | ------- | --------------------------------------- | | Core / Support | Full | Full | | Management | Full | Partial | | OATH | Full | Full | | PIV | Full | Full (no RSA3072/4096 raw sign/decrypt) | | OpenPGP | Full | Not available | | YubiOTP | Full | Partial (HMAC-SHA1 only) | | FIDO2 | Full | Partial (no credential management) |
Requirements
| | Minimum |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| React Native | 0.74+ with the New Architecture enabled |
| iOS | 16.4+ recommended (Podfile override required - the CocoaPods-trunk YubiKit pod is too old) |
| Android | minSdkVersion 24 |
Installation
npm install @doko/react-native-yubikit
# or
yarn add @doko/react-native-yubikit
# or
pnpm add @doko/react-native-yubikitiOS needs a Podfile override and a few entitlements depending on which transports you use; Android needs USB/NFC manifest entries. See Installation for the exact steps.
Quick start
import { YubiKeyProvider, useYubiKey } from '@doko/react-native-yubikit';
export default function App() {
return (
<YubiKeyProvider>
<DeviceScreen />
</YubiKeyProvider>
);
}
function DeviceScreen() {
const { devices, selectedDevice, startUsbDiscovery, stopUsbDiscovery } =
useYubiKey();
// startUsbDiscovery({ handlePermissions: true }) to begin listening,
// then read/write against selectedDevice.handle with any module below.
}import { Management, Oath, Piv } from '@doko/react-native-yubikit';
const info = await Management.getDeviceInfo(deviceHandle);
await Piv.verifyPin(deviceHandle, '123456');
const { credentials } = await Oath.getCredentials(deviceHandle);More examples for every module are in Usage Examples.
Example app
A runnable example app is included in example/ (Expo Router, demonstrates every supported module).
pnpm install
pnpm example startThen press a for Android or i for iOS.
Contributing
See CONTRIBUTING.md for the development workflow, build instructions, and how to send a pull request.
License
MIT
