React Native · APIs and utilities
Secure storage
Encrypted key-value store: for small secrets such as tokens and passwords (not for large data).
4 exports
Import
SecureStorage
moduleEncrypted key-value store: for small secrets such as tokens and passwords (not for large data). Values are strings; store objects with JSON.stringify.
| Name | Type | Description |
|---|---|---|
get | (key: string, options?: SecureStorageOptions) => Promise<string | null> | The value; null if missing. On iOS may be E_LOCKED while the device is locked. |
set | (key: string, value: string, options?: SecureStorageSetOptions) => Promise<void> | Writes the value (replaces it if present). |
delete | (key: string, options?: SecureStorageOptions) => Promise<void> | Deletes the value (does nothing if missing). |
has | (key: string, options?: SecureStorageOptions) => Promise<boolean> | Whether the value exists. |
keys | (options?: SecureStorageOptions) => Promise<string[]> | Keys in the namespace (sorted). |
clear | (options?: SecureStorageOptions) => Promise<void> | Deletes all values in the namespace (e.g. on sign out). |
iOS: when the value can be read.
afterFirstUnlock: from the first unlock after boot (background tasks can read it; carried to a new device with backups).whenUnlocked: only while the device is unlocked....ThisDevice: not carried to another device with backups.whenPasscodeSet: only while a device passcode is set; deleted when the passcode is removed.
SecureStorageOptions
interfaceCommon options.
| Name | Type | Default | Description |
|---|---|---|---|
service? | string | "default" | Separate namespace (e.g. per user). Letters, digits, ., -, _. |
SecureStorageSetOptions
interfaceSecureStorage.set options.
| Name | Type | Default | Description |
|---|---|---|---|
accessible? | SecureStorageAccessible | "afterFirstUnlock" | iOS accessibility. |
service? | string | "default" | Separate namespace (e.g. per user). Letters, digits, ., -, _. |