How to store tokens in react native?

前端 未结 6 1301
萌比男神i
萌比男神i 2021-02-05 05:59

I used to develop in android previously and i used to used SharePreference for storing user tokens. Is there anything such available in react native for both ios and android?

6条回答
  •  轮回少年
    2021-02-05 06:27

    Here are some ways to store persistent data in React Native:

    • async-storage stores unencrypted, key-value data. Do not use Async Storage for storing Token, Secrets and other confidential data. Do use Async Storage for persisting Redux state, GraphQL state and storing global app-wide variables.

    • react-native-keychain stores username/password combination in the secure storage in string format. Use JSON.stringify/JSON.parse when you store/access it.

    • react-native-sensitive-info - secure for iOS, but uses Android Shared Preferences for Android (which is not secure by default). There is however a fork) that uses Android Keystore.

    • redux-persist-sensitive-storage - wraps react-native-sensitive-info

    More info about React Native Storage & Security

提交回复
热议问题