Async Storage Bridge for lepont
You can use AsyncStorage through lepont.
npm i --save lepont @react-native-community/async-storage @lepont/async-storage
React Native side:
import React from 'react'
import { useBridge } from 'lepont'
import { WebView } from 'react-native-webview'
import { AsyncStorageBridge } from '@lepont/async-storage/bridge'
import AsyncStorage from '@react-native-community/async-storage'
const App = () => {
const [ref, onMessage] = useRegistry(AsyncStorageBridge(AsyncStorage))
return (
<WebView
source={{ uri: 'Web.bundle/index.html' }}
javaScriptEnabled={true}
ref={ref}
onMessage={onMessage}
/>
)
}
Browser side:
import { setItem, getItem } from '@lepont/async-storage'
await setItem('@storage_Key', { my: 'value' })
await getItem('@storage_Key') // => { my: 'value' }
MIT