Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to store user information in redux store or in local storage?

I'm wandering how to store user information after login?

Is it a good idea to store all the information in local storage or in redux store?

After successful login API return me a large object with user role and permission along with some other information.

I'm new in react-redux please help!

Thanks!

like image 300
Tech Aimley Avatar asked Dec 31 '22 11:12

Tech Aimley


1 Answers

Store user information in redux store. If you want to persist it (I do not recommend it, see details in this answer bellow) after reload of the application, you can use redux-persist.

But it really depends on what kind of authentication are you using. Generally you should use (and persist) only some authentication token (not the all user information). You can store this token in cookies and use it (for the backend request) for getting real user information (which you then store in redux store) on each application load.

like image 110
lavor Avatar answered Jan 05 '23 17:01

lavor