Firebase Authentication in React: A Step-by-Step Guide with Protected Routes

  Рет қаралды 8,038

from Dev To Prod

from Dev To Prod

Күн бұрын

Пікірлер: 34
@topfeature4492
@topfeature4492 9 ай бұрын
Source code here: bit.ly/3N9AbMl Subscribe if you like our content!
@joeythompson4530
@joeythompson4530 9 ай бұрын
Best tutorial I have seen for this! Quick and easy!
@topfeature4492
@topfeature4492 9 ай бұрын
Glad to hear! Thanks for your support!
@mr.artist486
@mr.artist486 7 ай бұрын
You saved my day! this is perhaps the best tutorial I have ever seen on this topic!! Thanks a lot!!!!! ❤❤
@topfeature4492
@topfeature4492 7 ай бұрын
I'm really glad to read that! And I appreciate your support!
@mr.artist486
@mr.artist486 7 ай бұрын
@@topfeature4492 If possible, can you release a video tutorial on SSDLC (secure software development life cycle) best practices?
@topfeature4492
@topfeature4492 10 ай бұрын
Timestamps: 00:00 - Intro 00:13 - Project setup 01:57 - Form creating 03:08 - Firebase setup 04:38 - Work with .env 05:15 - Creating Sign Up and Sign In methods 08:08 - Protected route 12:53 - Creating Sign Out method
@JoshuaIsrael-sl8vt
@JoshuaIsrael-sl8vt Ай бұрын
Your a live saver, this eaxactly what l needed at the moment
@topfeature4492
@topfeature4492 Ай бұрын
Glad to read that!
@ViciaiaTutorial
@ViciaiaTutorial 7 ай бұрын
you explained very simple and clear, thanks you for the tutorial!!!!
@topfeature4492
@topfeature4492 7 ай бұрын
I'm so happy you found it useful. Thanks!
@ViciaiaTutorial
@ViciaiaTutorial 7 ай бұрын
@@topfeature4492 wait to see more from you ^w^
@sethurk
@sethurk 8 ай бұрын
Pretty good. Short and precise. Thank you. subbed..
@topfeature4492
@topfeature4492 8 ай бұрын
Thanks for your support and subscribed!
@proflead
@proflead Ай бұрын
Nice guide! Thanks!
@topfeature4492
@topfeature4492 Ай бұрын
Welcome!
@ZiedMcHarek
@ZiedMcHarek 16 күн бұрын
Thanks for the great video. What do you think about using the ternary conditional operator? It makes the code a bit clearer. for example {isSignUpActive? Sign Up : Sign In}
@GenosoftTeamGen
@GenosoftTeamGen 5 ай бұрын
Great work thank you this is super neat
@topfeature4492
@topfeature4492 5 ай бұрын
Thank you for this comment!
@DiogoLScarmagnani
@DiogoLScarmagnani 5 ай бұрын
Great tutorial, very quick and simple. It works a lot. Got subscribed. I have just one question, please: Don't we need to persist access token in storage for Firebase Authentication?
@topfeature4492
@topfeature4492 5 ай бұрын
Glad to be helpful! What exactly storage did you mean?
@DiogoLScarmagnani
@DiogoLScarmagnani 5 ай бұрын
@@topfeature4492 sorry. I mean localStorage.
@MustafaCanDemir-c4w
@MustafaCanDemir-c4w 7 ай бұрын
Hey, great video btw, how to change path when sign in true? For example email and password is true then when i click the button, how to show private page directly
@topfeature4492
@topfeature4492 7 ай бұрын
Hi! Thanks for your support! If I got you right, the explanation starts here: 12:09. You need to add to your homepage (or any other public page with Login form) an extra condition to check if a user already logged in (=== if the user exists). If so, Navigate the user to the private page, like this: return UPD Or you can do it directly in the Auth handler function I guess. You can simply create an instance like: const browserHistory = createBrowserHistory() And then just call browserHistory.push(location) after successful login
@Mohit-rl4ct
@Mohit-rl4ct 5 ай бұрын
Amazing
@topfeature4492
@topfeature4492 5 ай бұрын
Thanks for your comment!
@placek2390
@placek2390 4 ай бұрын
how isfetching works? i dont understand why adding this magically solve the problem with rendering private page
@topfeature4492
@topfeature4492 4 ай бұрын
We render a private route based on the user's existence, and the ProtectedRoute component receives it from the parent component as a prop. The default user value is null, so if we try to access the private page, we will be redirected to the home page because there is no user. After that, let's imagine, the user was successfully set on the state. As we know, this state is defined outside the Routes tree. It means, that the state change will NOT lead to a re-render routes tree. The tree will only update after URL changes. Because of that, the user value inside ProtectedRoute will always be null (withour re-rendering it could not get a new prop value). Even after state changing on the top level. So, my solution here is to render the routes tree only when the user already exists. While we're fetching users asynchronously (isFetching === true) we want to return the loading component (not the routes tree). When the user is fetched we set it to state, then, set isFetching === false, and only after that we are returning a routes tree. It will be the first render and the user value will be correct at this moment.
@xczm225
@xczm225 7 ай бұрын
how you guys deal with view flashes when you are logged out and trying to get to any private route? for me it renders component for 0.1 sec and sends you back to '/'
@topfeature4492
@topfeature4492 7 ай бұрын
Hi! I tried to reproduce this behavior using my codebase, and everything seems to work correctly. You can compare your code with the following example github.com/from-dev-to-prod/react-firebase-auth Or, please, provide an example and I may be able to help.
@peacemelodi1145
@peacemelodi1145 8 ай бұрын
Nice content are you on Instagram sir
@topfeature4492
@topfeature4492 8 ай бұрын
Thank you! Not at the moment, but I’ll post a link when I do
@Abhishek7Shah
@Abhishek7Shah 5 ай бұрын
please can you make vedio of user and admin login in one project
@topfeature4492
@topfeature4492 5 ай бұрын
I guess I can try!
Deploy React App to GitHub Pages in 2 minutes
1:58
from Dev To Prod
Рет қаралды 260
Bike Vs Tricycle Fast Challenge
00:43
Russo
Рет қаралды 85 МЛН
Brawl Stars Edit😈📕
00:15
Kan Andrey
Рет қаралды 51 МЛН
отомстил?
00:56
История одного вокалиста
Рет қаралды 7 МЛН
How To Make a WordPress Blog - Step by Step
2:14:31
Tyler Moore
Рет қаралды 764 М.
Custom Protected Route Component in React
10:58
Cosden Solutions
Рет қаралды 44 М.
Авторизация в React-приложении с Firebase и Redux-Toolkit
47:24
Михаил Непомнящий
Рет қаралды 86 М.
User Authentication with React & Firebase: Full Tutorial
1:03:35
Daweb Schools • Learn to code today!
Рет қаралды 11 М.
Setting Up Google Authentication in Firebase 9: A Step-by-Step Guide
15:08
Brett Westwood - Software Engineer
Рет қаралды 17 М.