React Native Sync Storage: Turbo Native Module
Turbo Native Modules only work with the New Architecture enabled.
- Fully synchronous calls, no async/await, no Promises, no Bridge.
- Faster than AsyncStorage
- Uses JSI instead of the "old" Bridge
- iOS and Android support
npm install react-native-sync-storage-turbo-module
yarn add react-native-sync-storage-turbo-module
import { setItem, getItem, getAllKeys } from 'react-native-sync-storage-turbo-module';
// ...
setItem('myKey', 'My Value');
const value = getItem('myKey');
const keys = getAllKeys()
removeItem('myKey')
clear()
If you want to use react-native-sync-storage-turbo-module with redux-persist, create the following storage
object:
import { Storage } from 'redux-persist'
import { setItem, getItem, removeItem } from 'react-native-sync-storage-turbo-module';
export const reduxStorage: Storage = {
setItem: (key, value) => {
setItem(key, value)
return Promise.resolve(true)
},
getItem: (key) => {
const value = getItem(key)
return Promise.resolve(value)
},
removeItem: (key) => {
removeItem(key)
return Promise.resolve()
},
}
//...
const persistConfig = {
//...
storage: reduxStorage
}
const persistedReducer = persistReducer(persistConfig, rootReducer)
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT