Peter
Peter

Reputation: 45

Storing access token with Expo web

I've recently decided to try and make a universal app with expo supporting ios, android and web altogether. I knew that there would be many hick ups along the way.. but I found the biggest problem from the start. I can see that there are few options as where to store the access token for apps such as secure store or asyncStorage, I just simply can't find a way to work with cookies or any client side store to put in the access-token.

As my app should have the stay logged in feature essentially, this will be a critical problem for the web client.

Does anybody know a good workaround this matter, or is there a way to keep the users logged in from the server side using the device / ip detail..?

Please enlighten me guys!

Upvotes: 0

Views: 1563

Answers (3)

Nils Baumgartner
Nils Baumgartner

Reputation: 51

For andoid and ios you should use ExpoSecure Storage. For web I currently can only rely on the normal storage, but this seems not to be secure. One option would be to safe it in a cookie but thats something i dont realy like.

Upvotes: 0

alpere
alpere

Reputation: 1119

The web support is available in asyncStorage since v1.9.0.

So you can use it in recent versions of asyncStorage.

Upvotes: 1

AndreVitorio
AndreVitorio

Reputation: 930

I've managed to do this with AsyncStorage.

import AsyncStorage from '@react-native-community/async-storage';

/// Then inside your component make an asynchronous set
await AsyncStorage.setItem(['tokenName', tokenValue]);

Upvotes: 0

Related Questions