Article thumbnail

🔰 Authorization with useAuth hook

5m
frontend
ui
hooks

Intro

Let's implement a generic hook for handling any kind of authorization/authentication with an abstracted model and consistent API.

Why?

Authorization on frontend can be tricky. The logic of it varies depending on what we use for authorization. Suppose you have three methods of authorization - Google, Facebook and the usual login form.

For the application it should make no difference what kind of provider it is. So we need an abstraction that will give the application all the tools to authorize with any provider.

Usage

Loading

Implementation

Loading

I create content regularly!

I hope you found my post interesting. If so, maybe you'll take a peek at my LinkedIn, where I publish posts daily.

Comments

Add your honest opinion about this article and help us improve the content.

created: 20-03-2023
updated: 20-03-2023