After literaly 1 month failling to build protected Routes, using outlet and protected component from shitty tutorials, now finally with your way works! Thank you!
@FullstackSimplified Жыл бұрын
Glad it helped. Thanks for watching
@clementlin31402 жыл бұрын
This is gold!! Thanks for sharing the knowledge. Thumbs up and subscribed!
@FullstackSimplified2 жыл бұрын
Thankyou for subscribing..
@gokulap56442 жыл бұрын
While reloading a dashboard page it's redirects me to profile page. Will you help me 😊
@FullstackSimplified2 жыл бұрын
It reloads back to the profile page because when ever we reload we set the user in useEffect and the generic route which we have redirects us to the profile page. Instead of having the generic route with path=* outside the auth conditions we can have them separately for both the user states You can have a look at the code here - codesandbox.io/s/react-router-protected-routes-nynrfw?file=/src/App.js
@gokulap56442 жыл бұрын
@@FullstackSimplified ya got it thanks a lot love from india ❤️
@garbjorn17572 жыл бұрын
How about user role if admin or normal user. Because if I store in local storage it can be edited. How to make secure
@FullstackSimplified2 жыл бұрын
You can store it in session. And while making any api call your backend should also check if the req is coming form the expected user or not and then you can throw unauthorised error from your backend
@engineermaxwel67323 жыл бұрын
Its time you start making videos weekly I am your fan. Very simple and well explained, we owe you Monetization as your fan
@FullstackSimplified3 жыл бұрын
Thanks alot. Really appreciate your support. Was pretty occupied last month. You guys really motivate me. Will bring new videos soon. Thanks for watching 🔥🔥
@thecareercoach2313 жыл бұрын
Yes 😍
@FullstackSimplified3 жыл бұрын
Thank you ☺️
@Ayoutubeaccount32 жыл бұрын
One of the few tutorials that actually helped, thanks
@FullstackSimplified2 жыл бұрын
Glad it helped. Thanks for watching
@shivaa3ps1772 жыл бұрын
Hmm... You stood true to your channel name. Its definitely easy to follow what you have done.👌
@FullstackSimplified2 жыл бұрын
Glad you liked it. Thanks for watching 🔥
@vaibhavshetty37812 жыл бұрын
Thank you so much so how can we use this for admin and user
@FullstackSimplified2 жыл бұрын
You can define two roles within your state and render routes conditionally specific to your user's role
@feliprdev97622 жыл бұрын
wow, that was really simplified and still functional, i think that this logic will fit my project, thanks a lot 🙏
@FullstackSimplified2 жыл бұрын
Glad you liked it. Thanks for watching
@darkness974392 жыл бұрын
it's super simple and not complicated but the problem is when i want to have a 404 page you already use the "*" so how i will create my 404 page ? :/
@FullstackSimplified2 жыл бұрын
You can do something like this
@TheGroovySpace3 жыл бұрын
The way you explain the thing is great 👍👍👍👍
@FullstackSimplified3 жыл бұрын
Thank you
@willyhorizont86722 жыл бұрын
Bahut badhiya super!
@FullstackSimplified2 жыл бұрын
Thanks for watching
@fluffymaverick2 жыл бұрын
Thank you for the effort making this tutorial. Really helpful 👍
@FullstackSimplified2 жыл бұрын
Thanks for watching. Glad you liked it
@jaym30342 жыл бұрын
Thank you. A lot! Saving the user state is what I have been looking for!
@FullstackSimplified2 жыл бұрын
Glad it helped. Thanks for watching
@ratonconcigarro86122 жыл бұрын
This video is so usefully, thanks my friend :D
@FullstackSimplified2 жыл бұрын
Thanks for watching
@narayanbhagat5103 жыл бұрын
I am able to access the page like dashboard and profile using URL even after logout. how can I protect it ?
@raho_mania3 жыл бұрын
when you logout you shoud remove the user entry from localstorage
@FullstackSimplified3 жыл бұрын
Firebase signout function does it for you. Make sure you are setting the user state to null in onAuthChanged function when no user is found
@蹦太君-o4d2 жыл бұрын
wow so cool, this problem was confused me for a long time,but you explain so easy to understand!!!
@FullstackSimplified2 жыл бұрын
Glad you liked it!
@kritigoswami73823 жыл бұрын
Great explanation again. 😇
@FullstackSimplified3 жыл бұрын
Thank you
@JohnDoe-ej6vm2 жыл бұрын
wonderful explanation.
@FullstackSimplified2 жыл бұрын
Glad it helped. Thanks for watching 🔥
@vloggingwithMisha3 жыл бұрын
Such an amazing video ✨
@FullstackSimplified3 жыл бұрын
Thank you 🔥
@sujitrockstar2213 жыл бұрын
Helpful to all IT students.Nice video
@FullstackSimplified3 жыл бұрын
Thank you
@the_true_hier_to_the_sharingan2 жыл бұрын
Brilliant short videos but detailed and quick just what we need
@FullstackSimplified2 жыл бұрын
Thanks for watching 🔥
@gillesa2902 жыл бұрын
Very useful ! Thanks for sharing.
@FullstackSimplified2 жыл бұрын
Glad it helped. Thanks for watching
@thecareercoach2313 жыл бұрын
Great vdo ✨
@FullstackSimplified3 жыл бұрын
Thanks for watching 🔥
@h__m75512 жыл бұрын
thank you very much!! amazing video !!!!🙂🙂
@FullstackSimplified2 жыл бұрын
Thanks for watching!!
@tarik95632 жыл бұрын
Hi, followed every step with same code but still ended up with losing localstorage after refreshing the page or when I go to the profile or dashboard page tried everything in my beginner power but couldn't find the issue ! can you help me with any idea ? my react router dome is 6.3.0 now
@tarik95632 жыл бұрын
for whome they have the same problem as me, the solution is to call document.getElementById("root") last in the reactDom.render function and to remove reportWebVitals()
@FullstackSimplified2 жыл бұрын
Can you share your code snippet?
@baranoden2 жыл бұрын
You are the best and deserve more
@FullstackSimplified2 жыл бұрын
Thanks alot. Really appreciate your support 🔥🔥
@slablife2 жыл бұрын
Great job, very clear and concise. Sub'd!
@mohamedkalid87132 жыл бұрын
Nice Explanation bro, you make it easy 👌👌
@braham.prakash3 жыл бұрын
Exactly what i wanted Thanks man
@FullstackSimplified3 жыл бұрын
Thanks for watching
@sayyedaamerasharali75833 жыл бұрын
Thanks brother this helps me a lot. 👍
@FullstackSimplified3 жыл бұрын
Thanks for watching 🔥
@mihirharshe60732 жыл бұрын
Isn't verifying through a boolean value stored in localStorage really insecure as anyone can modify it?
@FullstackSimplified2 жыл бұрын
Storing the Boolean value is just for showing how things work. In real scenario you'll have a proper auth system which you can use to determine if the user is authenticated or not and accordingly render the routes
@asfnobambu2 жыл бұрын
Strait to the point !! Thank you :-)
@FullstackSimplified2 жыл бұрын
Thanks for watching
@rahulkrishna1643 жыл бұрын
Great video
@FullstackSimplified3 жыл бұрын
Thanks for watching
@akashbose36823 жыл бұрын
Nice to watch everything u explained ❤️
@FullstackSimplified3 жыл бұрын
Thanks for watching 🔥
@contactdi84262 жыл бұрын
What's the background music? Can you please share the name. That's beautiful. And Obviously, your videos are super helpful
You are amazing, you saved me from heart attack 🥰🤞🏾😋
@FullstackSimplified2 жыл бұрын
Glad you liked it!! Thanks for watching 🔥🔥
@cecibenitez39172 жыл бұрын
thanks I implemented this in my hobbie project, works perfect!
@FullstackSimplified2 жыл бұрын
Glad it helped. Thanks for watching
@guilhermematos74482 жыл бұрын
Very helpful
@FullstackSimplified2 жыл бұрын
Glad it helped
@clarkson93312 жыл бұрын
Thanks, i didnt know i can wrap code using &&. i was always doing { user ? : ... ) nice
@FullstackSimplified2 жыл бұрын
Glad it helped. Thanks for watching
@evoteck72732 жыл бұрын
I got an infinite loop after doing this keeps saying I can't call a setstate inside use Effect hook
@FullstackSimplified2 жыл бұрын
Please check if you have added an empty dependency array. useEffect(() => ....your code, [])
@onyilimba2 жыл бұрын
Nice tutorial, but why the background music though?
@FullstackSimplified2 жыл бұрын
Thanks for the feedback. Will fix this in the coming videos.
@TuanAnh-ll1lu3 жыл бұрын
thank you very much
@FullstackSimplified3 жыл бұрын
Thanks for watching
@kashmirtechtv29489 ай бұрын
What about showing and not showing Navbar?
@FullstackSimplified9 ай бұрын
You can do the similar thing, use ternary to show/hide navbar based on auth state
@maxwelochieng76582 жыл бұрын
Probably The Best Protected Routes I have Seen. But I have a suggestion for You is something that I am struggling with. I want to create a Website with Auth but after you log in we have a dashboard that contains nav links but everytime I include Link the Browser renders an empty page or the navbar disappears but I want the Nav bar to be static . I am beginner
@FullstackSimplified2 жыл бұрын
Make sure you use the Link component from react router dom and not tag.
@maxwelochieng76582 жыл бұрын
@@FullstackSimplified okay I'll get back to you
@danieltkach23302 жыл бұрын
Fantastic! Can you explain how to work with the token expiration, and also how to work with roles, whether the role should be saved on the token, please.
@FullstackSimplified2 жыл бұрын
You can save the token in localstorage and retrieve it everytime when you app mounts and check if the token is alive. For roles it would be better if you fetch it everytime from your backend when the app mounts for the first time
@JohnDoe-ej6vm2 жыл бұрын
i have 3 roles , public , student , admin . for each i want to have different routes and sidebar . what should be the flow ?
@FullstackSimplified2 жыл бұрын
If you have three roles so instead of storing the boolean value in the logged in state., you can use object or strings as roles and render the routes accordingly
@JohnDoe-ej6vm2 жыл бұрын
@@FullstackSimplified If isAdmin or isMode do this. { isAdmin || isMode && something }
@JohnDoe-ej6vm2 жыл бұрын
I am trying to do this . Can you please tell me what's my mistake in this ?
@profeskills7682 жыл бұрын
thank you :)
@FullstackSimplified2 жыл бұрын
Thanks for watching
@samnayakawadi2 жыл бұрын
Subscribed.
@FullstackSimplified2 жыл бұрын
Thanks. Really appreciate your support 🔥
@weslolo10742 жыл бұрын
Thank you!!!
@adilhashmi17352 жыл бұрын
there is a problem in this code it is navigating us to the "/profile" on reloading
@FullstackSimplified2 жыл бұрын
If you are storing the logged in state to 'true' in the local storage then it will load the profile page.
@yotsusan_machi2 жыл бұрын
note for me operator dan akan tampil jika semuanya bernilai true