I am building a react native frontend and used the auth system. Is there any way to persist session?

Each time I sign in it creates a new session. Is there a way to store this value with AsyncStorage and then send it with any requests from the app instead of the default localStorage?
2 Replies
airhorns
airhorns2w ago
hy @zy , there's no formal support for AsyncStorage from react-native right now. im not deeply familiar with react-native, but i see a couple options to getting this to work nice: - there might be a way to polyfill the localStorage global to be backed by AsyncStorage instead - the code that does this storage is open source here https://github.com/gadget-inc/js-clients/blob/main/packages/api-client-core/src/GadgetConnection.ts#L188-L201 if you wanted to open a PR or make a local patch that makes it work the way you want! also just FYI, the session token stored in localStorage is sensitive in the sense that if someone has it, they can do anything the user can do, it is like a password. i was just reading the AsyncStorage is unencrypted, so it might be better to find an alternative that is encrypted!
zy
zyOP2w ago
amazin - looks like the polyfill worked, thank you! swapped out for expo-secure-store

Did you find this page helpful?