Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access cookies with React Native Expo

I'm fairly new to React Native and Expo, and I'm confused about how cookies are managed. I have an Express server that sets a token cookie in a response (res.cookie("jwt",token)). Somehow when my React Native client makes an authentication request and receives a response, the client stores the cookie somewhere, and the token is passed in future requests (with credentials: "include"), until I restart the emulator. My main questions are

  • Where are these cookies stored?
  • How can I access them?
  • I was under the impression that React Native doesn't really support cookies. Is this functionality specific to Expo?
  • If I were to deploy this as a real mobile app, can I rely on this cookie behavior, or should I use one of the React Native cookie management packages?

Thank you in advanced for your help!

like image 932
Henry Avatar asked Oct 30 '25 05:10

Henry


1 Answers

ReactNative does not have this support by default as it runs on the native side (well, you do have support on the WebView component but that's isolated)

If you are relying on Expo they are still figuring out the cookies management, you can follow the updates in this issue, they are aware about the persistence of cookies been inconsistent between app loads:

https://github.com/expo/expo/issues/6756

If you have to use the cookies anyway I would suggest to use this lib, it seems quite stable, but maybe you will need to implement some integrations with your API yourself:

https://github.com/react-native-cookies/cookies

Wish success on your project.

like image 107
Luís C Meireles Avatar answered Nov 01 '25 20:11

Luís C Meireles



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!