Search code examples
sql-serverreact-nativeauthenticationjwtexpress-jwt

Authentication of React native app with express js back end


I have developed Angular, express js web application with JWT authentication. Now I need to develop react native mobile app for the same purpose as a web application. How can I add authentication for react native app. should it need to use JWT for the react native app or are there any other authentication techniques for the mobile application. I'm new to react native as well as mobile app development. Give me some recommended guides for react native and express js back-end development. Both web application and mobile application has the same database implemented using MSSQL.


Solution

  • You can of course use the JWT strategy. I suggest you to use the AsyncStorage to store your token or any other data.

    https://reactnative.dev/docs/asyncstorage

    For the authentication you could create an AuthenticationContext where to provide all the functions and logic you need for the authentication.

    Inside the context you could have function to login and to logout, a function to store the user in the AsyncStorage, a function to remove the user from the AsyncStorage, a function to determine whether the user is authenticated and other logic according to your needs.