No video

Authenticate Your Next.js Apps Using Firebase: Complete Guide

  Рет қаралды 25,766

Code Ryan

Code Ryan

Күн бұрын

Github: github.com/cod...
In this tutorial, I cover how to authenticate users within your Next.js app router applications using Firebase. I cover signing in, signing out, and signing up.

Пікірлер: 78
@eugenebesedovsky
@eugenebesedovsky 4 ай бұрын
To prevent a home page to flash just use 'return router.push("...")' instead of 'router.push("...")'. Thus you won't see the home page if you're not signed in. Also can use 'loading' variable coming second from useAuthState hook to render some fallback component. So there won't be any need of adding session storage item.
@user-ys2ru7ic8t
@user-ys2ru7ic8t 5 ай бұрын
Thanks for sharing this guide! You made a comment about making errors toward the end of the video. I just came here to say that I was looking for this video, and there were a few available... but the other ones I looked at were guys that jump-cut through their mistakes, and they'd copy and paste all of their code so you wouldn't see them typing. Those videos are awful to follow along with. Yours is relatable. Keep doing it the way you're doing it! We're here because we're making mistakes too.
@coderyan
@coderyan 5 ай бұрын
Thank you for the kind words, very much so appreciated!
@Rawailsakib
@Rawailsakib 5 ай бұрын
Rayan your best is that you always reply to your learners without hurting them this is your best then your skills
@coderyan
@coderyan 5 ай бұрын
Thank you!
@Rawailsakib
@Rawailsakib 4 ай бұрын
@@coderyan your welcome man!
@fengtaka
@fengtaka Ай бұрын
This is definitely one of the best tutorials I've watched Easy to understand and literally solved an issue I thought would take me hours in such a short time. Thanks!
@coderyan
@coderyan Ай бұрын
Happy to hear it! Thank you
@MrBlazzerBoy
@MrBlazzerBoy 8 ай бұрын
Also please do one for protecting routes: show those pages only if user is logged in.
@yashraj4855
@yashraj4855 8 ай бұрын
Awesome guide! Got my thing working in one go. Thanks a lot 😊.
@coderyan
@coderyan 8 ай бұрын
Happy to hear it!
@ukaszStrzelecki
@ukaszStrzelecki 8 ай бұрын
Hi Ryan! Thanks for this tutorial. Can you make full example how to use Firebase Auth also using SSR and proper session storage thru whole application? There is a lot of this kind of tutorials were you can find examples how to signin/login/signout but it ends at this step. Thanks a lot!
@ionutsandu5913
@ionutsandu5913 7 ай бұрын
I successfully managed to do what you're asking for my company but it was quite tricky. This weekend I will create a repo if you'd like so you can get some help from there.
@ajithm1690
@ajithm1690 6 ай бұрын
@@ionutsandu5913Hi! Can you please share your repo/GitHub username. I’m learning firebase Auth it would be great if you could share it. Thanks
@MikeBritton
@MikeBritton 6 ай бұрын
@@ionutsandu5913 Very kind of you, if the offer still stands.
@ajithm1690
@ajithm1690 5 ай бұрын
@@ionutsandu5913can you share the repo url? Thanks in advance
@emokiniovoaghogho7420
@emokiniovoaghogho7420 Ай бұрын
​@@ionutsandu5913hey, pls can you send me the repo link? I'm working on a project that is supposed to use those features and I have no idea how to go about it
@proflead
@proflead 17 күн бұрын
Thanks for the tutorial Rayan!
@coderyan
@coderyan 17 күн бұрын
You’re welcome!
@davidlintin
@davidlintin 6 ай бұрын
27:36 "I'm gunna change this to jsx because I like the Icon better" - also me.
@coderyan
@coderyan 6 ай бұрын
Haha glad you can relate
@Growingmindsetalha
@Growingmindsetalha 8 ай бұрын
it is not adding the user in the data base
@isagive
@isagive 4 ай бұрын
Thank you brother. the userSession solution seems wrong - the useAuthState changes so maybe we need to wrap in a function and wait for it? i dont know but it still kicks out a lot of error after routing. In anycase, thank you for the hard work very helpfull tutorial
@alexandergeorgesquire220
@alexandergeorgesquire220 4 ай бұрын
Hey thanks Ryan Just wondering... Why are you using .env for the config files? The docs say the cofnig data is safe to be on the front end?
@TheJoyBoySSK
@TheJoyBoySSK 6 күн бұрын
My problem is that there is no code written in SignIn.js file that checks the databse for users and then signs them in, it just creates a new user in signIn itself, removing the need for signup and leading to multiple entries of same users everytime they login
@lucasrodrigues680
@lucasrodrigues680 6 ай бұрын
Thank you for the guide. It helped me a lot! The only issue that I had was the errors. The react-firebase-hook did not throw some of my errors automatically. I had to get the errors from the hook and then throw it manually. Something like this: const [signInWithEmailAndPassword, user, loading, error] = useSignInWithEmailAndPassword(auth) try { const res = await signInWithEmailAndPassword(data.email, data.password) if(error){ throw new Error(error.message) } reset() router.push('/my-chats') } catch(err) { console.error(err) }
@gokulnaathb2627
@gokulnaathb2627 7 ай бұрын
Thank you so much, Ryan, this will help me.
@coderyan
@coderyan 7 ай бұрын
You’re welcome!
@janeeshafernando6830
@janeeshafernando6830 6 ай бұрын
Thankyou soo much. Its working 😍🥰
@coderyan
@coderyan 6 ай бұрын
Happy to hear it!
@Growingmindsetalha
@Growingmindsetalha 8 ай бұрын
why is it giving the res undefined?
@M7ilan
@M7ilan 7 ай бұрын
you’re so good can you make a same tutorial but showing user data? or maybe username system?
@brookt5725
@brookt5725 4 ай бұрын
Have you tried going to / without signing in it displays the content for a short while which is really bad thing
@coderyan
@coderyan 4 ай бұрын
Should have covered this in the video, but can be solved in several ways, one of which is by using some loading state
@brookt5725
@brookt5725 4 ай бұрын
@@coderyan Wouldn't that be redundant to do that on each page
@coderyan
@coderyan 4 ай бұрын
Wouldn’t need to do it at each page. You can do it higher up in the application (e.g in the root component)
@solorashed
@solorashed 8 ай бұрын
I don't get the point, If you make all page use client then why you are using next?
@scor32k
@scor32k 8 ай бұрын
ig he did this for tutorial purpose, we can rectify the code.
@ionutsandu5913
@ionutsandu5913 7 ай бұрын
@@scor32k Not really. All firebase hooks need client to run. Having a SSR auth with firebase is quite tricky.
@user-hr4rl2cz1h
@user-hr4rl2cz1h 6 ай бұрын
@@ionutsandu5913 you're right, I don't understand why everyone is making video with NextJS title but just handling the issues same as simple React.
@marioperez6180
@marioperez6180 7 ай бұрын
The thing is you are doing it only in client side
@vyxian00
@vyxian00 15 күн бұрын
yes, this is okay only if you're using firebase as database since firebase will handle backend protection via security rules.
@ahmedabdel-aal8404
@ahmedabdel-aal8404 8 ай бұрын
great video helped me a lot, keep it up
@coderyan
@coderyan 8 ай бұрын
Happy it helped you out
@darkside0094
@darkside0094 5 ай бұрын
thanks man, i've been following the official docs but kept on getting errors. Is "react-firebase-hooks" library a must in order to use firebase with next js?
@alikawu7145
@alikawu7145 2 ай бұрын
Will this make all the components client components?
@StatsOverStyles
@StatsOverStyles 2 ай бұрын
that was awesome and so easy to use
@coderyan
@coderyan 2 ай бұрын
Happy it helped!
@juancabanas268
@juancabanas268 4 ай бұрын
How can I refresh the user idToken after expiration? How is that process? After 1 hour, the user is not retrieved and no refreshed id is gotten. Please, I'm really stuck in that process 🙏. I'm building a PWA with NextJS and I need the user to always be signed in
@Imraann0
@Imraann0 Ай бұрын
Can you not handle the user logged in information with get server side props for the home component
@priyapandey8951
@priyapandey8951 8 ай бұрын
Can't we directly use the config js file for the storing values of those variables? Why are we using them as env variables? Is it some kind of convention to do so?
@nosrehcorporation
@nosrehcorporation 8 ай бұрын
Safety, you dont want to expose those values in your regular packages
@priyapandey8951
@priyapandey8951 8 ай бұрын
@@nosrehcorporation ok thankyou sir
@iancarr3923
@iancarr3923 5 ай бұрын
Excellent video as usual. Just one plea from littl ol' England on presentation. Please try to avoid saying "go ahead and" too often. Thanks.
@mitaligupta8635
@mitaligupta8635 5 ай бұрын
I am getting an error of module not found in page.js file for config.js file for auth. But I have already made that file.
@user-ds8ll1ec3w
@user-ds8ll1ec3w 8 ай бұрын
Hi! Thank you for this video! How did you use async/await in client component? I have an error when try it
@Route-20
@Route-20 Ай бұрын
Thank you.
@fluffsenpai
@fluffsenpai 6 ай бұрын
The home page still flashes when going to the original URL. if the page was to be protected its not.
@tabmax22
@tabmax22 2 ай бұрын
should firebase env vars be added to vercel platform to a prod app as NEXT_PUBLIC_...?
@pedromendoza8148
@pedromendoza8148 3 ай бұрын
Is this going to make all the app a client component?
@Vlada97my
@Vlada97my 7 ай бұрын
I have a question, how can i sing up users and set their first and last name?
@aarondean1872
@aarondean1872 5 ай бұрын
How would you move the Auth logic into something like an Auth Context?
@phptempaltedf
@phptempaltedf 4 ай бұрын
it's full ClientSide when we use Firebase auth?
@Fluttydev
@Fluttydev 6 ай бұрын
is this secured to store use in session storage ?
@Minu_Shalom
@Minu_Shalom Ай бұрын
Hi Ryan! Maybe I'm wrong, but as I know NEXT_PUBLIC will be included in the client-side JavaScript bundle, making them accessible to anyone who can inspect the website's source code.
@CptJuke
@CptJuke 5 ай бұрын
hey man great video! It gives me an error ''sessionStorage is not defined" when i try to deploy. Any idea how to solve it?
@shreyashraj
@shreyashraj 5 ай бұрын
'use client'; add this line in top of your page
@CptJuke
@CptJuke 5 ай бұрын
@@shreyashraj its already in a client side component :(
@shreyashraj
@shreyashraj 5 ай бұрын
@@CptJuke maybe you forgot to import sessionStorage
@juanpabloarroyochavez7311
@juanpabloarroyochavez7311 4 ай бұрын
Hello, I have the same problem, could you solve it?
@CptJuke
@CptJuke 4 ай бұрын
@@juanpabloarroyochavez7311 sadly no 😞
@Ilovemonkey123
@Ilovemonkey123 2 ай бұрын
I love you
@jabedalamakash8558
@jabedalamakash8558 9 ай бұрын
thanks
@coderyan
@coderyan 9 ай бұрын
You’re welcome
@Viviko
@Viviko 6 ай бұрын
… Oh. So I have to use hooks and shit… alright. That makes my life easier. I’m used to calling some API instead of FireBase and then storing JWTs. So this is kinda weird. And I’m used to working in SolidJS or Svelte. So this is weird for me.
Learn Next.js Parallel Routes In 16 Minutes
16:18
Web Dev Simplified
Рет қаралды 125 М.
Before VS during the CONCERT 🔥 "Aliby" | Andra Gogan
00:13
Andra Gogan
Рет қаралды 10 МЛН
王子原来是假正经#艾莎
00:39
在逃的公主
Рет қаралды 17 МЛН
白天使选错惹黑天使生气。#天使 #小丑女
00:31
天使夫妇
Рет қаралды 15 МЛН
Joker can't swim!#joker #shorts
00:46
Untitled Joker
Рет қаралды 41 МЛН
Master NextAuth v5: Next.js Authentication Made Easy
31:35
Code Ryan
Рет қаралды 8 М.
Angular Firebase Authentication - Implement Auth in Minutes
22:23
Monsterlessons Academy
Рет қаралды 11 М.
Easy Next.js & NestJS Authentication with Clerk
33:23
Michael Guay
Рет қаралды 7 М.
Next.js Authentication Firebase - Sign in with Google
36:54
Code Commerce
Рет қаралды 40 М.
All 29 Next.js Mistakes Beginners Make
1:45:10
ByteGrad
Рет қаралды 116 М.
Next.js App Router Authentication (Sessions, Cookies, JWTs)
11:31
Before VS during the CONCERT 🔥 "Aliby" | Andra Gogan
00:13
Andra Gogan
Рет қаралды 10 МЛН