NextJS + Firebase V9 Authentication tutorial

Поділитися
Вставка
  • Опубліковано 13 гру 2024

КОМЕНТАРІ • 96

  • @nielsmichael8345
    @nielsmichael8345 2 роки тому +9

    Incredible job. I spent days reading articles trying to figure this out and you taught me in 30 minutes. Really clear explanation behind the logic and everything too so that I actually understood better what I was doing instead of just copying you. Thank you and God bless!

    • @samquarton9509
      @samquarton9509 2 роки тому

      Completely agree with above. Awsome job, helped me heaps and very clear!

  • @Tech2Code
    @Tech2Code Рік тому +1

    this video made my day

  • @motive.2024
    @motive.2024 2 роки тому +7

    Great tutorial, just a key note, useRouter() is not with `next/rounter` in NextJS 13 , replacement is `next/navigation`

    • @k-c
      @k-c 2 роки тому +1

      Thanks for the tip

  • @dextar256
    @dextar256 Рік тому

    Thank you so, so much. Spent hours going through articles and videos that were just complicating the solution. This was very straightforward and well explained. The fact that you left out "types" shows how much you value simplicity when teaching, thanks mhn.

  • @beta82
    @beta82 2 роки тому

    Amazing tutorial, I spent hours trying to figure out auth until I found your video, Great job!

  • @emanuelefavero
    @emanuelefavero Рік тому

    This is an awesome tutorial man. The only thing I would've add is a 'starter-template' folder in the github repo for when you pasted all that code at the start

  • @devmesh5340
    @devmesh5340 2 роки тому

    Thanks a ton!! I struggled for a whole week to get firebase authentication to work. I learned a lot from you.

  • @DaNussi
    @DaNussi 2 роки тому

    for those who have problems with "useContext(AuthContext)". You have to change "createContext({})" to "createContext({}, () => {})"

  • @rupeshadhav9511
    @rupeshadhav9511 11 місяців тому

    Thank you so much brother. Its very helpful❤

  • @AliKhaladj
    @AliKhaladj Рік тому

    Awsome, You saved me lots of time bro!

  • @mjsupm4404
    @mjsupm4404 2 роки тому

    Thanks so much Sairaj 🙏🙏 Really appreciate your work! Complete Authentication tutorial including protected routes. You're awesome 💯

  • @thecoderabbi
    @thecoderabbi 2 роки тому +2

    Thanks for this video, I wished I had found it since yesterday night, I hope this video gets more activity so it can rank higher in search! I did this with GatsbyJS and it worked just fine!!

  • @saraohman97
    @saraohman97 Рік тому

    I don't have this , what do I wrap in ?

  • @sarkseven
    @sarkseven Рік тому

    Great video man

  • @fhkodama
    @fhkodama 2 роки тому

    Awesome! It worked well here! Thanks, man! Really helpful! :)

  • @SprintKeyz
    @SprintKeyz 2 роки тому

    Amazing tutorial, easy to understand and worked very well! Thank you for sharing your knowledge!

  • @bbok1616
    @bbok1616 2 роки тому

    thx, great tutorial, it helped me figured out how to structure auth utilities

  • @kainicholas2526
    @kainicholas2526 Рік тому

    God amongst men!

  • @franklinoduro7274
    @franklinoduro7274 2 роки тому

    i loved your explanation. thank you

  • @AbdurrahmanASUR
    @AbdurrahmanASUR 2 роки тому

    but there is a problem. when i reload or enter the protected page when i m logged in the protectedRoute work and redirect me to the home page and i m logged in

  • @alexg7282
    @alexg7282 2 роки тому

    Works for me thank you !

  • @maverick_wolfe
    @maverick_wolfe 2 роки тому

    Works perfectly! Thank you and God bless you!

  • @aikude
    @aikude Рік тому

    Would be great to see this used to protect NextJS API routes.

  • @og33927
    @og33927 2 роки тому

    This is the great tutorial. thank you

  • @isagive
    @isagive 2 роки тому

    How do use {children} statement (that u used inside ProtectedRoute in a js file?

  • @playcarri2148
    @playcarri2148 Рік тому

    Does exist any vulnerability in a loggin like this?

  • @CyrilOkidi
    @CyrilOkidi 2 роки тому

    Great tutorial. Flash of unauthenticated contents still appear on my end though.

  • @AbdurrahmanASUR
    @AbdurrahmanASUR 2 роки тому

    thank you for ProtectedRoute😍😍😍😍

  • @MIKERM
    @MIKERM 2 роки тому

    Nice explication and work, very helpful, thanks man!

  • @Chinni0913
    @Chinni0913 2 роки тому

    getting undefined when the user is logged in. is there any solution for this undefined?

  • @marcelomagalhaes6619
    @marcelomagalhaes6619 2 роки тому

    Awesome! The best course 🙏

  • @raiyanthedeveloper
    @raiyanthedeveloper 2 роки тому +2

    Can I use these protected routes in Production that you have shown in the video ??? And Thank you for the tutorial.

    • @sairajchouhan
      @sairajchouhan  2 роки тому +1

      Thanks for watching and Ya definitely you can use it in prod, you can also make it more strict or customise it as you want it to behave, it's all yours

  • @YourTechWhiz
    @YourTechWhiz Рік тому

    Why don't you used nextjs middelware function?

  • @JohnnyOshika
    @JohnnyOshika 2 роки тому +1

    This is only client-side auth, so your server-side logic won't know who the signed in user is. Very good tutorial, but it's important to be aware of this limitation.

    • @JohnnyOshika
      @JohnnyOshika 2 роки тому

      This is the technique you'll want to use (i.e. good old cookies) if you want the server to be aware of auth data: ua-cam.com/video/kRszxpeTnW0/v-deo.html

  • @christianmiguez1379
    @christianmiguez1379 Рік тому

    How can I also add Google sign-up - in ?

  • @bread90210
    @bread90210 Рік тому

    Thanks, This helped me resolved my problem. However, there is a little bug in the code, inside the user context, the else is resetting the user to empty when the page reloads, so i removed that part and the user object still retains the data even after page refresh

  • @johnpaulperez3240
    @johnpaulperez3240 2 роки тому

    It redirects when you access specific link. How to fix this ?

  • @kalebschmottlach4036
    @kalebschmottlach4036 2 роки тому

    if you want to prevent redirect if someone refreshes the page then you have to call on state change directly

  • @devshaad
    @devshaad 2 роки тому

    Bro which vs code theme and font u are using

  • @dertuman
    @dertuman Рік тому

    Awesome! Thank you!

  • @eniolaadejori9114
    @eniolaadejori9114 2 роки тому

    How do you persist the logged in state

  • @mahdibeldjoudi3269
    @mahdibeldjoudi3269 2 роки тому

    This vid helped me a lot thanks man

  • @tayanefernandes4434
    @tayanefernandes4434 2 роки тому

    Amazing video!!

  • @touseefibnkhaleel3643
    @touseefibnkhaleel3643 2 роки тому

    on 20:20, why is it rendering everytime when you type, can you not make it render once when the user hits the submit button?

    • @sairajchouhan
      @sairajchouhan  2 роки тому

      Because it's controled input that is managed by react it renders every time we type

  • @AJGaming-cg9og
    @AJGaming-cg9og 7 місяців тому

    thank you so much sir

  • @ductran4639
    @ductran4639 2 роки тому

    My dashboard page and its component is flashed for a few sec before it redirects me to the login page. Anyone else?

  • @rajenderkatkuri7642
    @rajenderkatkuri7642 2 роки тому

    Hey Greta work! What is the theme and font you use in VS Code?

  • @imrraaj
    @imrraaj 2 роки тому

    Extremely helpful thank you

  • @skverskk
    @skverskk 2 роки тому

    Nicely done. Does Firebase Auth have an email confirmation upon signup whereby a user gets a signup link in his inbox?

  • @tinmank
    @tinmank 2 роки тому

    I'm trying to get JWT token to initialize Apollo, but I couldn't manage, where would be the best way to place apollo initialization?

    • @sairajchouhan
      @sairajchouhan  2 роки тому

      Apollo is it on frontend or backend?
      If it's backend then it's pretty simple and you can get the idToken from firebase and send that to your backend

    • @tinmank
      @tinmank 2 роки тому

      @@sairajchouhan Thank you for the reply, Apollo is in the frontend.

    • @sairajchouhan
      @sairajchouhan  2 роки тому +1

      @@tinmank I am sorry I don't have enough expertise to answer this

    • @tinmank
      @tinmank 2 роки тому

      @@sairajchouhan No worries, thank you.

  • @Jun_Mun
    @Jun_Mun 2 роки тому

    i keep getting an error at this line 'export const auth = getAuth()' - FirebaseError: Firebase: Error (auth/invalid-api-key).
    i have also checked thru the config.....google search not providing a clear answer at the moment LOL will you be able to help?

    • @sairajchouhan
      @sairajchouhan  2 роки тому

      Sure that's because of wrong or mismatched credentials when you initialise firebase

  • @emre-mz4sc
    @emre-mz4sc 2 роки тому

    can we do that authentication with redux instead of context?

  • @josephmartin6219
    @josephmartin6219 2 роки тому

    Thank you so much for the guide, please what's the name of your vscode font?

  • @MavlonbekMuratov
    @MavlonbekMuratov 2 роки тому

    great tutorial. thank you.

  • @ratneshthakur6776
    @ratneshthakur6776 2 роки тому

    Which font and theme are you using? It really looks awesome.

  • @frontcodelover
    @frontcodelover 2 роки тому

    Really nice job mate !
    An error happen if a people try to signup 2 times with the same email. Do u have a solution or can you record another tutorial for that ?
    Thank you

  • @jakubjazdzyk2315
    @jakubjazdzyk2315 Рік тому

    Thank you!

  • @ShahidAli-tn8je
    @ShahidAli-tn8je 2 роки тому

    Which extension do you use for code intelicience?

  • @vinivilares
    @vinivilares 2 роки тому

    Valeu amigo indiano salvou thanks bro

  • @theharrypeter_xd1237
    @theharrypeter_xd1237 2 роки тому

    how do we use that displayName?

    • @sairajchouhan
      @sairajchouhan  2 роки тому

      I guess you are asking where can we use the displayName property on the user object (which is the state) in AuthContext
      if that's the question, then we can use displayName of user in Navbar just beside to logout, so that user can see by which account he has logged in, and on clicking that link we can redirect to the profile page (if we have one)

    • @youeyeyouex7427
      @youeyeyouex7427 2 роки тому

      return createUserWithEmailAndPassword(auth, email, password).then(async () => {
      await updateProfile(auth.currentUser, {
      displayName: 'username handled by useState'
      })
      })
      user.displayName

  • @armandasbarkauskas4485
    @armandasbarkauskas4485 2 роки тому

    Worked

  • @deveshb793
    @deveshb793 2 роки тому

    loved the video

  • @zhanezar
    @zhanezar 2 роки тому

    why does useEffect run 3 times in console @27:12 ? and does this matter for performance? also can you do a tutorial about Iron sessions ? i think this helps to keep user logged in so that there is no loading required because session is from cookie but I am not sure .... Thank you for the tutorial :)

    • @sairajchouhan
      @sairajchouhan  2 роки тому

      That is not in useEffect I logged the user below the useEffect so one is when firebase identifies user state changes one is route change and other is normal render ig, typically we should be wrapping the functions like login and signup inside of useCallback to improve the performance
      And I have no idea about iron session, I will check it out thanks for the suggestions

  • @danieljonet7608
    @danieljonet7608 2 роки тому

    you need of an gx40 official bro

  • @harshmakwana934
    @harshmakwana934 2 роки тому

    bro i need video on the same thing but i need to update my users name validate email and other stuff i hope you see this soon

    • @sairajchouhan
      @sairajchouhan  2 роки тому

      There are well documented APIs to do this
      Checkout firebase.google.com/docs/auth/web/manage-users

  • @xavierxavier3610
    @xavierxavier3610 2 роки тому

    27:40

  • @ProfessionalDebugger
    @ProfessionalDebugger 2 роки тому

    thanks

  • @kingcoding3587
    @kingcoding3587 2 роки тому

    Up

  • @scripticstudios2022
    @scripticstudios2022 2 роки тому

    6:18 hope u didn’t type in your actual password bc we can all see it

  • @austincodes
    @austincodes 2 роки тому

    IDK why we are wasting our time with bootstrap. I came for a tutorial about firebase.

  • @YannEazy
    @YannEazy 2 роки тому

    Thank you for this tutorial Sairaj.
    Although I'm stucked with an error, could you help me with that ?
    TypeError: (0 , _firebase_util__WEBPACK_IMPORTED_MODULE_0__.getModularInstance)(...).onAuthStateChanged is not a function

  • @hemanthnvd3103
    @hemanthnvd3103 2 роки тому

    Thanks dude ❤helped me a lot.