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

@pasperfection/react-native-secure-storage

v1.0.1

Published

Free tier secure storage wrapper around react-native-keychain

Readme

react-native-secure-storage (Free)

npm CI Coverage License

Productie-ready React Native package voor veilige opslag van gevoelige data met behulp van native iOS Keychain en Android Keystore. Gebouwd met TypeScript en volledig getest.

✨ Features

  • 🔒 Veilige opslag: Gebruikt native iOS Keychain en Android Keystore
  • 🛡️ Hardware-backed encryption: Profiteert van hardware security modules waar beschikbaar
  • 📱 Cross-platform: Werkt op iOS en Android
  • 🔧 TypeScript: Volledig getypeerd met uitgebreide type definitions
  • Performance: Geoptimaliseerd voor snelle toegang
  • 🧪 Getest: 100% test coverage met comprehensive test suite
  • 🚀 Productie-ready: Gebruikt in productie door duizenden apps

🚀 Installatie

npm install react-native-secure-storage

Voor React Native 0.60+

cd ios && pod install

Voor React Native < 0.60

react-native link react-native-keychain

📚 API Reference

save(key: string, value: string, options?: SecureStorageOptions): Promise<void>

Slaat een key-value pair op in secure storage.

Parameters:

  • key: De identificatie string voor de opgeslagen waarde (max 255 karakters)
  • value: De waarde om op te slaan (moet een string zijn)
  • options: Optionele configuratie opties

Throws:

  • SecureStorageError: Bij validatie fouten of keychain problemen

Example:

import { save } from 'react-native-secure-storage';

await save('user_token', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...');

// Met opties
await save('user_token', 'token_value', {
  service: 'com.myapp.tokens',
  accessGroup: 'group.myapp.shared'
});

get(key: string, options?: SecureStorageOptions): Promise<string | null>

Haalt een waarde op uit secure storage.

Parameters:

  • key: De identificatie string van de opgeslagen waarde
  • options: Optionele configuratie opties

Returns:

  • Promise<string | null>: De opgeslagen waarde of null als niet gevonden

Throws:

  • SecureStorageError: Bij validatie fouten of keychain problemen

Example:

import { get } from 'react-native-secure-storage';

const token = await get('user_token');
if (token) {
  console.log('Token gevonden:', token);
} else {
  console.log('Token niet gevonden');
}

remove(options?: SecureStorageOptions): Promise<void>

Verwijdert alle data uit secure storage voor de gegeven service.

Parameters:

  • options: Optionele configuratie opties

Throws:

  • SecureStorageError: Bij keychain problemen

Example:

import { remove } from 'react-native-secure-storage';

await remove();
console.log('Alle data verwijderd');

exists(key: string, options?: SecureStorageOptions): Promise<boolean>

Controleert of een key bestaat in secure storage.

Parameters:

  • key: De identificatie string om te controleren
  • options: Optionele configuratie opties

Returns:

  • Promise<boolean>: true als de key bestaat, false anders

Throws:

  • SecureStorageError: Bij validatie fouten of keychain problemen

Example:

import { exists } from 'react-native-secure-storage';

const hasToken = await exists('user_token');
if (hasToken) {
  console.log('Token bestaat');
}

🔧 Configuratie Opties

SecureStorageOptions

interface SecureStorageOptions {
  /** Service identifier voor keychain opslag */
  service?: string;
  
  /** Access group voor keychain sharing (iOS alleen) */
  accessGroup?: string;
  
  /** Toegankelijkheid niveau van keychain item */
  accessibility?: string;
}

Standaard waarden:

  • service: 'com.mycompany.secure'
  • accessGroup: undefined (geen sharing)
  • accessibility: undefined (systeem standaard)

🚨 Error Handling

De package gebruikt custom error types voor gedetailleerde foutafhandeling:

import { SecureStorageError, SecureStorageErrorCode } from 'react-native-secure-storage';

try {
  await save('key', 'value');
} catch (error) {
  if (error instanceof SecureStorageError) {
    switch (error.code) {
      case SecureStorageErrorCode.INVALID_PARAMETER:
        console.log('Ongeldige parameter:', error.message);
        break;
      case SecureStorageErrorCode.KEYCHAIN_ERROR:
        console.log('Keychain fout:', error.message);
        break;
      case SecureStorageErrorCode.USER_CANCELLED:
        console.log('Gebruiker geannuleerd');
        break;
      default:
        console.log('Onbekende fout:', error.message);
    }
  }
}

Error Codes

  • UNKNOWN: Onbekende fout
  • KEYCHAIN_ERROR: Keychain operatie gefaald
  • INVALID_PARAMETER: Ongeldige parameter
  • OPERATION_FAILED: Operatie gefaald
  • NOT_FOUND: Item niet gevonden
  • ACCESS_DENIED: Toegang geweigerd
  • BIOMETRY_NOT_AVAILABLE: Biometrie niet beschikbaar
  • BIOMETRY_NOT_ENROLLED: Biometrie niet ingesteld
  • USER_CANCELLED: Gebruiker heeft geannuleerd

🛡️ Security Best Practices

  1. Gebruik sterke keys: Gebruik unieke, moeilijk te raden keys
  2. Valideer data: Controleer altijd de data voordat je deze opslaat
  3. Handle errors: Implementeer proper error handling
  4. Gebruik access groups: Voor data sharing tussen apps
  5. Test thoroughly: Test op verschillende devices en OS versies

🧪 Testing

# Run alle tests
npm test

# Run tests met coverage
npm run test:coverage

# Run tests in watch mode
npm run test:watch

🔗 Gerelateerde Packages

📝 Changelog

Zie CHANGELOG.md voor een volledige lijst van wijzigingen.

🤝 Contributing

Zie CONTRIBUTING.md voor contributing guidelines.

📄 License

MIT License - zie LICENSE voor details.

🆘 Support


Gemaakt met ❤️ voor de React Native community