expo-storage-universal-web
v0.3.8
Published
Web implementation of expo-storage-universal
Readme
expo-storage-universal-web
Web implementation of expo-storage-universal.
Features
WebRegularStorage: Non-secure storage implementation usingsessionStorageWebSecureStorage: Secure storage implementation usingsessionStorage(Note: For truly secure storage, use NativeSecureStorage on native platforms)
Installation
# Install both packages
npm install expo-storage-universal expo-storage-universal-webNote: expo-storage-universal is a peer dependency of this package.
Usage
import {
WebRegularStorage,
WebSecureStorage,
} from 'expo-storage-universal-web';
// For regular storage
const regularStorage = new WebRegularStorage();
await regularStorage.save('userId', '12345');
const userId = await regularStorage.find('userId');
await regularStorage.remove('userId');
// For secure storage
const secureStorage = new WebSecureStorage();
await secureStorage.save('authToken', 'your-token');
const token = await secureStorage.find('authToken');
await secureStorage.remove('authToken');API
WebRegularStorage
find(key: string): Promise<string | undefined>- Retrieves a value from storagesave(key: string, value: string): Promise<void>- Saves a value to storageremove(key: string): Promise<void>- Removes a value from storage
WebSecureStorage
find(key: string): Promise<string | undefined>- Retrieves a value from storagesave(key: string, value: string): Promise<void>- Saves a value to storageremove(key: string): Promise<void>- Removes a value from storage
Development
# Install dependencies
npm install
# Run tests
npm test
# Build
npm run build
# Type checking
npm run typecheck
# Linting
npm run lintLicense
MIT
