Member-only story

Configuring a React app to handle Authentication without redux, with Hooks

Marcos Henrique da Silva
8 min readJun 2, 2020

This is a very short tutorial to show one of several approaches to handle Authentication in React

Hi there, in this article I want to show one simple way to handle Authentications in React, without redux!

The story of a lot single page applications are almost the same:

I want a single page application that I can control user registration and flows depending if the user is logged or not or which kind of permissions the user have. But, since React gives me several tools to do it, how can I configure it?

In this article I am showing one of several ways that you could try to handle it in a easy way (at least it seems ok for me).

To get started, here are some minimum requirements for the article:

  • Some knowledge of Javascript
  • Basic understanding of React, React Route and Hooks
  • I am using React 16.13.1 for this article
  • Redux knowledge not needed
  • Basic HTML/CSS knowledge
  • Basic npm understanding.

Responses (2)

Write a response

Good article, I like it! I must say it, Context API it’s really convenient, most of the times, and it makes your code cleaner.

--

I think this is a good article but misses the final step of persisting the jwt in either a session storage or local storage it would be great to see how you approach this last remaining piece.

--