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

@shaaz1000/rn-storage

v1.0.3

Published

A comprehensive storage solution for React Native with encryption, caching, and offline sync

Readme

@shaaz1000/rn-storage

A powerful and flexible storage solution for React Native applications with built-in support for encryption, caching, and offline synchronization.

Features

  • 🔒 Secure data encryption
  • 📦 Efficient caching system
  • 🔄 Offline data synchronization
  • ⚡ High-performance storage
  • 🎯 TypeScript support
  • ✨ React Hooks for easy integration

Installation

npm install @shaaz1000/rn-storage

# Required peer dependencies
npm install @react-native-async-storage/async-storage @react-native-community/netinfo

Basic Usage

import { StorageManager, useStorage } from '@shaaz1000/rn-storage';

// Initialize the storage (do this in your app's entry point)
StorageManager.initialize('your-secure-key');

// Use in your components
function MyComponent() {
  const { value, setValue, loading } = useStorage('my-key', initialValue);
  
  return (
    <View>
      {loading ? <ActivityIndicator /> : <Text>{value}</Text>}
    </View>
  );
}

Available Hooks

1. useStorage

General-purpose storage hook with all features.

const { 
  value, 
  setValue, 
  remove, 
  loading, 
  error 
} = useStorage(key, initialValue, {
  encrypt: true,
  cache: true,
  sync: true,
  expiryTime: 3600000 // 1 hour
});

2. useCache

Specialized hook for caching with automatic cleanup.

const { 
  value, 
  setCache, 
  removeFromCache, 
  clearCache 
} = useCache(key, initialValue, {
  expiryTime: 3600000,
  encryptData: false
});

3. useEncryptedStorage

Hook specifically for handling encrypted data.

const { 
  value, 
  setValue, 
  remove 
} = useEncryptedStorage(key, initialValue);

4. useOfflineSync

Hook for managing offline data synchronization.

const { 
  syncStatus, 
  lastSyncTime, 
  pendingOperations, 
  queueOperation, 
  forceSync 
} = useOfflineSync({
  syncInterval: 5000,
  retryAttempts: 3,
  onSyncComplete: (success) => console.log('Sync completed:', success),
  onSyncError: (error) => console.error('Sync failed:', error)
});

Advanced Usage

Custom Encryption

import { StorageManager, Encryption } from '@shaaz1000/rn-storage';

// Initialize with a strong encryption key
StorageManager.initialize('your-secure-encryption-key');

// Store encrypted data
await StorageManager.getInstance().setItem('secure-key', sensitiveData, true);

Caching with Size Limits

import { CacheManager } from '@shaaz1000/rn-storage';

const cache = CacheManager.getInstance({
  maxSize: 100, // Maximum items in cache
  expiryTime: 1000 * 60 * 60, // 1 hour
  encryptData: true
});

await cache.set('key', data);

Offline Sync Configuration

import { OfflineSync } from '@shaaz1000/rn-storage';

const sync = OfflineSync.getInstance();

sync.configure({
  syncInterval: 5000, // Sync every 5 seconds
  retryAttempts: 3,
  onSyncComplete: (success) => {
    console.log('Sync status:', success);
  },
  onSyncError: (error) => {
    console.error('Sync failed:', error);
  }
});

API Reference

StorageManager

  • initialize(key: string): Initialize storage with encryption key
  • getInstance(): Get storage instance
  • setItem(key: string, value: any, encrypt?: boolean): Store data
  • getItem(key: string, decrypt?: boolean): Retrieve data
  • removeItem(key: string): Remove data
  • clear(): Clear all data

CacheManager

  • getInstance(config?: CacheConfig): Get cache instance
  • set(key: string, value: any, expiryTime?: number): Cache data
  • get(key: string): Get cached data
  • remove(key: string): Remove from cache
  • clear(): Clear cache

OfflineSync

  • getInstance(): Get sync instance
  • configure(config: SyncConfig): Configure sync
  • queueOperation(operation: QueueItem): Queue operation for sync
  • syncQueuedItems(): Force sync
  • stopSync(): Stop sync process

TypeScript Support

The package includes full TypeScript definitions. Example with custom types:

interface UserData {
  id: number;
  name: string;
}

const { value, setValue } = useStorage<UserData>('user', {
  id: 0,
  name: ''
});

Error Handling

All hooks provide error states and handling:

const { error, value, setValue } = useStorage('key', initialValue);

if (error) {
  console.error('Storage error:', error.message);
}

Best Practices

  1. Initialize early in your app:
// App.tsx or index.js
StorageManager.initialize('your-secure-key');
  1. Handle loading states:
const { value, loading } = useStorage('key', null);

if (loading) {
  return <LoadingSpinner />;
}
  1. Use encryption for sensitive data:
const { value } = useEncryptedStorage('api-token', null);
  1. Configure cache expiry appropriately:
const { value } = useCache('user-preferences', null, {
  expiryTime: 1000 * 60 * 60 * 24 // 24 hours
});

License

MIT