Domain-Driven Design storage system for React Native apps with type-safe AsyncStorage operations.
npm install @umituz/react-native-storagereact>= 18.2.0react-native>= 0.74.0@react-native-async-storage/async-storage>= 1.21.0
- ✅ Domain-Driven Design (DDD) architecture
- ✅ Type-safe storage operations
- ✅ Result-based error handling
- ✅ React hooks for easy integration
- ✅ Storage key management utilities
- ✅ Automatic serialization/deserialization
import { useStorage, StorageKey } from '@umituz/react-native-storage';
const MyComponent = () => {
const storage = useStorage();
// Get item
const value = await storage.getItem('my-key', 'default-value');
// Set item
await storage.setItem('my-key', 'my-value');
// Remove item
await storage.removeItem('my-key');
// Clear all
await storage.clear();
};import { StorageKey, createUserKey, createAppKey } from '@umituz/react-native-storage';
// Create typed storage keys
const userKey = createUserKey('preferences');
const appKey = createAppKey('settings');
// Use with storage
const storage = useStorage();
await storage.setItem(userKey, { theme: 'dark' });import { useStorageState } from '@umituz/react-native-storage';
const MyComponent = () => {
const [value, setValue, isLoading] = useStorageState('my-key', 'default');
return (
<View>
<Text>{value}</Text>
<Button onPress={() => setValue('new-value')} />
</View>
);
};useStorage(): Main storage hook for CRUD operationsuseStorageState(key, defaultValue): React state hook with storage persistence
StorageKey: Type-safe storage key classcreateUserKey(key): Create user-specific storage keycreateAppKey(key): Create app-wide storage key
storageRepository: Direct access to storage repositoryAsyncStorageRepository: Repository implementation class
MIT