Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-cookie vs universal-cookie vs react-cookies

I am using JWT to create and verify tokens and store the token in a cookie. (react front end vs Nodejs backend)

I am confused about the use of react-cookie vs universal-cookie and react-cookies.

What is the difference between these and what is the difference between setting cookies on the back-end vs the front-end?

like image 254
Abdul Ahad Avatar asked Jun 01 '19 09:06

Abdul Ahad


1 Answers

I haven't used any of these packages however, all of those packages wrap native JavaScript methods for a simple use of cookies. Feel free to pick whichever you feel more comfortable with.

Regarding to your second question, there is no difference between them technically. Cookie is a browser-related feature and it's always handled by the browser.

If you set cookies in the back-end, server will add a cookie header that the browser will read and save it.

If you set them in the front-end, document.cookie will be interpreted and cookies get saved by your browser.

like image 51
Mücahit Inel Avatar answered Sep 28 '22 07:09

Mücahit Inel