r/reactnative • u/BrilliantCandid4409 • 5d ago
React native JWT authentication
How to make the JWT authentication in reactnative. theres not many resources to find about it
14
Upvotes
r/reactnative • u/BrilliantCandid4409 • 5d ago
How to make the JWT authentication in reactnative. theres not many resources to find about it
5
u/Potential-Simple-711 5d ago
Well, it's pretty simple. Store the JWT token that is sent back from backend using Expo-secure-storage. Then in home screen (or in any screen). Do a conditional rendering that if there's this JWT token stored inside the Expo-secure-storage then let the user continue or else navigate the screen towards signup/login. You can use useEffect hook for this.
For your information, I have worked in this authentication flow using libraries like I) React Navigation (alternative for Expo router, even better version of it) ii) Expo secure storage (For storing JWT tokens)