Expo.SecureStore

Is there a proper documentation on how to use Expo SecureStore?
I’m new to react-native and I am building a login function to save a user id globally to be accessible throughout the app.

2 Likes

https://docs.expo.io/versions/v28.0.0/sdk/securestore

I have a homemade Stor component in which I incorporate SecureStore:

import Expo from 'expo' 

const Stor = async (key: string, value?: Object) => {

  let json = ''

  if ('object' == typeof value) {
    Expo.SecureStore.setItemAsync(key, JSON.stringify(value))
  }
  else {
    json = await Expo.SecureStore.getItemAsync(key)
    return json
  }

}

export default Stor

Usage:

import Stor from './Stor'

...

let obj = {
  something: 'hey there'
}

Stor('some_key', obj) // Stores the object as a string.

let my_var = Stor('some_key') // Gets the stringified value out of storage.
2 Likes

cool thanks!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.