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

@devraj-labs/rn-storage-kit

v0.3.2

Published

Unified storage API for React Native — MMKV key-value, Keychain secrets, and structured logging behind one interface

Downloads

549

Readme

npm version license react-native TypeScript


rn-storage-kit gives you three batteries-included storage primitives behind a single, consistent async get/set/remove/clear interface:

| Primitive | Backed by | Use for | |-----------|-----------|---------| | MMKVStorageAdapter | react-native-mmkv | Preferences, cache, state | | SecureStorageAdapter | react-native-keychain | Tokens, passwords, secrets | | Logger | MMKV-persisted, TTL-aware | Debug traces, production safety |


Installation

npm install @devraj-labs/rn-storage-kit

Peer dependencies

npm install react-native-mmkv react-native-keychain

Follow the native setup guides for both libraries:


Usage

MMKV storage

Fast, synchronous storage wrapped in a promise-based interface.

import { MMKVStorageAdapter } from '@devraj-labs/rn-storage-kit';

const storage = new MMKVStorageAdapter();
// optionally scope to a named MMKV instance:
const storage = new MMKVStorageAdapter('my-app.settings');

await storage.set('theme', 'dark');
const theme = await storage.get('theme');   // 'dark'
await storage.remove('theme');
await storage.clear();
const keys = await storage.getAllKeys();

Secure storage (Keychain)

Identical interface — swap the adapter, get hardware-backed encryption.

import { SecureStorageAdapter } from '@devraj-labs/rn-storage-kit';

const secure = new SecureStorageAdapter();

await secure.set('auth_token', 'eyJ...');
const token = await secure.get('auth_token');
await secure.remove('auth_token');
await secure.clear();
const keys = await secure.getAllKeys();

Secure values are stored in Keychain via setGenericPassword per key. A key index is maintained in a dedicated MMKV instance (rn-storage-kit.secure-index) so getAllKeys and clear work without Keychain enumeration support.


Logger

Production-safe structured logging for every storage operation. Disabled by default.

Enable

Call once at app startup, before any storage operations:

import { enableLogger } from '@devraj-labs/rn-storage-kit';

enableLogger({
  level: 'debug',           // 'none' | 'error' | 'info' | 'debug'
  maxEntries: 200,          // FIFO cap (default: 200)
  ttl: 0,                   // auto-evict entries older than N ms (0 = off)
  allowInProduction: false, // never logs in prod unless explicitly set
});

Disable

import { disableLogger } from '@devraj-labs/rn-storage-kit';

disableLogger();

Read and clear logs

import { getLogs, clearLogs } from '@devraj-labs/rn-storage-kit';

const entries = getLogs(); // TStorageLogEntry[]
clearLogs();

Subscribe to new entries

import { onNewLog, offNewLog } from '@devraj-labs/rn-storage-kit';

const handler = (entry) => console.log(entry);
onNewLog(handler);
// later:
offNewLog(handler);

Log levels

| Level | What is recorded | |-------|-----------------| | none | Nothing | | error | Failed operations only | | info | All operations — key and adapter visible, values/results stripped | | debug | Full detail — key, value, result, duration. Secure values are always masked as *** |

Log entry shape

type TStorageLogEntry = {
  id: string;
  timestamp: number;
  adapter: 'mmkv' | 'secure';
  operation: 'set' | 'get' | 'remove' | 'clear' | 'getAllKeys';
  key?: string;
  value?: string;   // '***' for secure ops; absent at info level
  result?: string | null;
  error?: string;
  durationMs: number;
  secure: boolean;
};

Persistence

Logs survive Metro fast-refresh via a dedicated MMKV instance (rn-storage-kit.logs). Writes are async via setImmediate — zero impact on storage call performance. Secure values never reach the log store.


Production safety

  • Logger is a no-op in production unless allowInProduction: true is passed to enableLogger.
  • Secure adapter values are always logged as ***, regardless of log level.
  • At info level, value and result fields are stripped from all log entries.

API reference

MMKVStorageAdapter

| Method | Signature | Description | |--------|-----------|-------------| | constructor | (id?: string) | Custom MMKV instance ID. Default: 'rn-storage-kit.default' | | get | (key: string) => Promise<string \| null> | Returns value or null | | set | (key: string, value: string) => Promise<void> | Stores a string value | | remove | (key: string) => Promise<void> | Deletes a key | | clear | () => Promise<void> | Clears the entire MMKV instance | | getAllKeys | () => Promise<string[]> | Returns all stored keys |

SecureStorageAdapter

Same interface as MMKVStorageAdapter. Backed by Keychain via setGenericPassword / getGenericPassword per service key.

Logger

| Export | Signature | Description | |--------|-----------|-------------| | enableLogger | (options?: TLoggerOptions) => void | Activates logging | | disableLogger | () => void | Deactivates logging | | getLogs | () => TStorageLogEntry[] | Returns a copy of all current entries | | clearLogs | () => void | Clears entries from memory and MMKV | | onNewLog | (cb: TLogListener) => void | Subscribe to new entries | | offNewLog | (cb: TLogListener) => void | Unsubscribe |


Project structure

src/
  mmkv-storage/    MMKVStorageAdapter + TStorageAdapter type
  secure-storage/  SecureStorageAdapter (Keychain-backed)
  logger/          Logger state, enableLogger, log levels, MMKV persistence
  types/           Shared type definitions
  index.ts         Public barrel

License

MIT