Pros: It’s convenient.
Authorization Bearer ${access_token}.Cons: It’s vulnerable to XSS attacks.
Pros: The cookie is not accessible via JavaScript; hence, it is not as vulnerable to XSS attacks as localStorage.
Cons: Depending on the use case, you might not be able to store your tokens in the cookies.
cookies: Cookies are the data stored in the form of key-value pairs that are used to store information about the user on their computer by the websites that the users browse and use it to verify them.
authorization: Authorization is the process of giving someone the ability to access a resource.
access control: Access control is a security technique that regulates who or what can view or use resources in a computing environment. It is a fundamental concept in security that minimizes risk to the business or organization.
conditional rendering: Conditional rendering is a term to describe the ability to render different user interface (UI) markup if a condition is true or false. In React, it allows us to render different elements or components based on a condition. This concept is applied often in the following scenarios:
What is Redux?
It helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test. On top of that, it provides a great developer experience, such as live code editing combined with a time traveling debugger.
While it’s mostly used as a state management tool with React, you can use it with any other JavaScript framework or library.
When to use Redux
Redux allows you to manage your app’s state in a single place and keep changes in your app more predictable and traceable. It makes it easier to reason about changes occurring in your app.
Redux usually used when your app grows to the scale where managing app state becomes a hassle; and you start looking out for making it easy and simple.
What is state management in Redux?
How Redux works
The way Redux works is simple. There is a central store that holds the entire state of the application. Each component can access the stored state without having to send down props from one component to another.
There are three building parts: actions, store, and reducers.
Actions in Redux
Reducers in Redux
Store in Redux
References:
@By Michelle Wirantono/LocalStorage vs Cookies: All You Need To Know About Storing JWT Tokens Securely in The Front-End
@By cookiepro/What is a Third-Party Cookie?