expo-storage-universal-native
Version:
Native implementation of expo-storage-universal
73 lines (50 loc) • 1.75 kB
Markdown
Native implementation of [expo-storage-universal](https://github.com/higayasuo/expo-storage-universal).
- `NativeRegularStorage`: Non-secure storage implementation using `@react-native-async-storage/async-storage`
- `NativeSecureStorage`: Secure storage implementation using `expo-secure-store`
```bash
npm install expo-storage-universal-native expo-storage-universal
```
```typescript
import {
NativeRegularStorage,
NativeSecureStorage,
} from 'expo-storage-universal-native';
// For regular storage (non-secure)
const regularStorage = new NativeRegularStorage();
await regularStorage.save('userId', '12345');
const userId = await regularStorage.find('userId');
await regularStorage.remove('userId');
// For secure storage
const secureStorage = new NativeSecureStorage();
await secureStorage.save('authToken', 'your-token');
const token = await secureStorage.find('authToken');
await secureStorage.remove('authToken');
```
- `find(key: string): Promise<string | undefined>` - Retrieves a value from AsyncStorage
- `save(key: string, value: string): Promise<void>` - Saves a value to AsyncStorage
- `remove(key: string): Promise<void>` - Removes a value from AsyncStorage
- `find(key: string): Promise<string | undefined>` - Retrieves a value from SecureStore
- `save(key: string, value: string): Promise<void>` - Saves a value to SecureStore
- `remove(key: string): Promise<void>` - Removes a value from SecureStore
```bash
npm install
npm test
npm run build
npm run typecheck
npm run lint
```
MIT