NextJS + Firebase Tutorial 🔥 // Hooks, Firestore, Authentication & Functions!

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ย. 2024

ความคิดเห็น • 104

  • @JarrodWatts
    @JarrodWatts  2 ปีที่แล้ว +19

    Hey Everyone! Important note for those starting out a new Firebase project below.
    This video is using the v8 version of Firebase. Google has recently released a v9 version of Firebase that is more modular and optimized.
    You can still follow along this tutorial, a lot of it is still relevant. However some of the code snippets you'll find will be slightly different/outdated, with the new v9 version of Firebase.

    • @hirosyee
      @hirosyee 2 ปีที่แล้ว +5

      What are changes you already know ??

    • @yellowbonbon1
      @yellowbonbon1 2 ปีที่แล้ว

      @@hirosyee same question

    • @JohnBuildWebsites
      @JohnBuildWebsites 2 ปีที่แล้ว +1

      FirebaseUI is incompatible with v9 version of firebase

    • @JohnBuildWebsites
      @JohnBuildWebsites 2 ปีที่แล้ว

      @Bagshot Thanks - I had similar issues trying to follow this tutorial so thought best to share. Glad it was worth the time.

    • @RawFatGod
      @RawFatGod 2 ปีที่แล้ว

      Thanks for letting us know.

  • @outis99
    @outis99 3 ปีที่แล้ว +27

    Honestly mate this is so good, a fast and concise video I can revisit whenever I want to start a new Next/Firebase project.
    Personally I love this fast informative videos like Fireship does but I imagine they require a lot of editing so don't feel pressure to make all of them like this

    • @JarrodWatts
      @JarrodWatts  3 ปีที่แล้ว +8

      Thanks so much! Definitely takes a bit of time to edit them together, but I have taken a lot of inspiration from Fireship as I love his style of videos too :)

  • @RockstarProgrammer
    @RockstarProgrammer ปีที่แล้ว +3

    This is already out of date in 2023:
    error - TypeError: Cannot read properties of undefined (reading 'apps')

  • @alexwarendh
    @alexwarendh 3 ปีที่แล้ว +3

    Jarrod! Amazing video! I'm starting to find "my" stack and this is spot on.

    • @JarrodWatts
      @JarrodWatts  3 ปีที่แล้ว +1

      Thanks so much Alexander! It's such a fun stack to work with, I'm using it for my current project as well, hoping to make some more firebase + Next.js content soon too!

    • @alexwarendh
      @alexwarendh 3 ปีที่แล้ว

      @@JarrodWatts Looking forward to even more content! I really appreciate the saas perspective of it all as well.

  • @thekanimation
    @thekanimation 2 ปีที่แล้ว +1

    This was fantastic. Thanks a lot

  • @cryptodev2615
    @cryptodev2615 2 ปีที่แล้ว +7

    I get a SyntaxError: Cannot use import statement outside a module error when deploying functions

    • @markyun8606
      @markyun8606 2 ปีที่แล้ว

      I am having same error, have you find out a solution?

  • @cristiankeibersbardelotto
    @cristiankeibersbardelotto 3 หลายเดือนก่อน

    good work!
    excellent video and explanation!

  • @isadarc11
    @isadarc11 ปีที่แล้ว

    Great video! thanks so much! you covered so much in such a little amount of time!

  • @codelabspro
    @codelabspro ปีที่แล้ว +2

    Getting error - Module not found: Can't resolve firebaseui/StyledFirebaseAuth when I follow these steps

  • @saeedet19
    @saeedet19 3 ปีที่แล้ว

    Right to the point! amazing. Good job Jarrod! Thanks for sharing it.

  • @Daddytronics
    @Daddytronics 2 ปีที่แล้ว

    Great tutorial. Fast paced

  • @lonesomesam
    @lonesomesam 2 ปีที่แล้ว

    Great video man. Surely helped a lot, thanks.

  • @denosorus
    @denosorus 2 ปีที่แล้ว

    Best tutorial on youtube

  • @JonathanIhm
    @JonathanIhm 3 ปีที่แล้ว

    This is really great content, this was exactly what I was looking!

    • @JarrodWatts
      @JarrodWatts  3 ปีที่แล้ว

      Thank you so much Jonathan! That has made my day :-)

  • @LatinoWebStudio
    @LatinoWebStudio 2 ปีที่แล้ว

    Thanks so much for the video!

  • @magmalife7330
    @magmalife7330 2 ปีที่แล้ว

    1:08 YOU BEAST

  • @PshemoPL
    @PshemoPL 2 ปีที่แล้ว +4

    I wonder if exposing envs with api keys to the browser via NEXT_PUBLIC prefix is a good idea. It will be inlined in your JS bundle and thus available for public eyes. Without this prefix it won't work tho.
    Any idea how to handle this issue?

    • @Ruslan-bv4mp
      @Ruslan-bv4mp 2 ปีที่แล้ว

      Running into the same issue. You can use JWT in the middleware to generate your own access token and using this in the application but will lose tha ability to use Google SIgn In ect...

  • @davidlintin
    @davidlintin ปีที่แล้ว

    No idea why so many people add the user to the db client side. Fb functions is the best way to do this well done.

  • @jawyor-k3t
    @jawyor-k3t 2 หลายเดือนก่อน

    why did you use cloud functions for signup? couldn't you "manually" create a document when user clicks on the sign up button?

  • @BetterTechSol
    @BetterTechSol 7 หลายเดือนก่อน

    Thank you!

  • @omfj
    @omfj 2 ปีที่แล้ว

    I am a year late, but WOW, what a great tutorial!

  • @raiyanthedeveloper
    @raiyanthedeveloper 2 ปีที่แล้ว

    Thank you so so much

  • @abhishekvishwakarma9045
    @abhishekvishwakarma9045 2 ปีที่แล้ว

    Thanks your video helped me a lot

    • @JarrodWatts
      @JarrodWatts  2 ปีที่แล้ว

      Thanks for letting me know Abhishek, glad it helped!

  • @bobbyLovesTech
    @bobbyLovesTech 3 ปีที่แล้ว

    Thank you so much!!!

  • @xExcisionx
    @xExcisionx 3 ปีที่แล้ว

    Thanks, great tutorial!

    • @JarrodWatts
      @JarrodWatts  3 ปีที่แล้ว

      Thank you Ruben! Really glad you liked it!

  • @tomascarignano5002
    @tomascarignano5002 2 ปีที่แล้ว

    Thank you!!!!!

  • @guilhermemoraferia
    @guilhermemoraferia 2 ปีที่แล้ว +2

    Great video, I keep getting this error if anyone could help me:
    ReferenceError: Cannot access '__WEBPACK_DEFAULT_EXPORT__' before initialization
    webpack default export being firebase at firebaseClient

    • @daylightismine1718
      @daylightismine1718 2 ปีที่แล้ว

      I also get this error and have no idea what to do. Did you figure it out?

    • @guilhermemoraferia
      @guilhermemoraferia 2 ปีที่แล้ว

      @@daylightismine1718 I sort of magically started working after a while idk why, maybe it had something todo with cache or sm, what I suggest is you try and restart your PC, that might work.

  • @Moochers
    @Moochers 2 ปีที่แล้ว

    How could I do it so that I use one button instead of two. Like a heart button for example. A ternary statement that if the user has "no" you turn it yes and vice versa. edit : I just figured it out. My next problem is that I'm using this method to make likes on some cards. The thing is that each card is unique. This method makes all card have the like... any way I can make them different?

  • @williambjork2777
    @williambjork2777 ปีที่แล้ว +2

    @4:14 Are you using some sort of key command/plugin to convert the config values into Next config values when pasting into the env.local file? Or did you just edit the video or am i a complete idiot? (bit of both perhaps)

    • @Nano-hb5kf
      @Nano-hb5kf หลายเดือนก่อน

      have you find out? i'm in the same situation😂

    • @williambjork2777
      @williambjork2777 25 วันที่ผ่านมา

      @@Nano-hb5kf Dont remember lol. But pretty sure I just wrote the env variables by hand and copied the values from my firebase account one by one

  • @robin9436
    @robin9436 3 ปีที่แล้ว

    Thanks a ton!

    • @JarrodWatts
      @JarrodWatts  3 ปีที่แล้ว

      No worries, glad you liked it and thanks for the kind comment :)

  • @shawn-skull
    @shawn-skull ปีที่แล้ว +1

    Ok. Chat GPT solved in a second all the issues about the outdated stuff related to firebase and FirebaseUI for me.
    What I don't understand yet is why you used functions to manage the users collection. Is it there any particular reason to do it so? Isn't not secure to handle it like the votes collection?

  • @Moochers
    @Moochers 2 ปีที่แล้ว

    Is there anyway to use this method for a like button? I would need to make the like/unlike unique to the post ID

  • @AI913
    @AI913 ปีที่แล้ว

    I'm using TypeScript, and at 9:01 , there is an error
    Argument of type 'CollectionReference' is not assignable to parameter of type 'Query'.
    Type 'CollectionReference' is missing the following properties from type 'Query': converter, typets(2345)
    I don't know how to fix it. Anyone knows?

  • @momenwadood1342
    @momenwadood1342 ปีที่แล้ว

    Thanks for the video, how to pre render the votes list using SSR after each vote?

  • @Deepakguptasky
    @Deepakguptasky 2 ปีที่แล้ว

    Wonderful video .If you deploy this app on vercel. Will it work fine ?

  • @nicobonder
    @nicobonder ปีที่แล้ว

    AS this video has 2 years, I cant make work. He uses import firebase from "../firebase/clientApp"; but when I want to use it firebase is undefined. Someone can help to solve this issue? Thanks.

  • @takesomecoffee2363
    @takesomecoffee2363 3 ปีที่แล้ว +2

    I cannot make firebasui work for some silly css and node modules error

    • @hesamalavi9
      @hesamalavi9 3 ปีที่แล้ว +1

      use import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth';
      in your auth.js file instead of the import in the tutorial

    • @JarrodWatts
      @JarrodWatts  3 ปีที่แล้ว +2

      @@hesamalavi9 Thanks mate! If it helps, the source code for the Auth file is here too: github.com/jarrodwatts/pineapple/blob/main/components/Auth.tsx

    • @hesamalavi9
      @hesamalavi9 3 ปีที่แล้ว

      @@JarrodWatts Thank you mate for this great video

    • @jakubkurdziel2407
      @jakubkurdziel2407 3 ปีที่แล้ว

      The same problem, thanks for resolve

    • @cryptodev2615
      @cryptodev2615 2 ปีที่แล้ว +1

      @@hesamalavi9 thanks so much for the fix ✌

  • @mmareplays4610
    @mmareplays4610 2 ปีที่แล้ว +1

    I get this error from the clientApp file "TypeError: Cannot read properties of undefined (reading 'apps')". anyone has that too?

    • @oliverhoad5838
      @oliverhoad5838 2 ปีที่แล้ว

      Yep, me too

    • @AI913
      @AI913 2 ปีที่แล้ว

      Did you fix it?

  • @glitchinthematrix3934
    @glitchinthematrix3934 2 ปีที่แล้ว +1

    Hey Jarrod I just came across an article about how this current method exposes our env to browser which isn't secure. Is there any secure method to do so?

    • @JarrodWatts
      @JarrodWatts  2 ปีที่แล้ว

      Hey would you mind sending me the article for me to take a look at?

  • @matt-analoguelife
    @matt-analoguelife 3 ปีที่แล้ว +2

    Upto Auth - so far so good. Except, if you have 'Block 3rd party Cookies' set in Chrome Settings you cannot login with either Github or Google in my case.

    • @JarrodWatts
      @JarrodWatts  3 ปีที่แล้ว +1

      Good to hear Matthew! That's an interesting point, would you normally have 3rd party cookies disabled for blocking tracking/ads?

  • @chinmayabisoi3890
    @chinmayabisoi3890 11 หลายเดือนก่อน

    A question though, why do we need cloud function to create user? We can simply create it like we were doing for vote document right?

    • @theceohq
      @theceohq 7 หลายเดือนก่อน

      You could, but it's not recommended. The main reason is that you risk exposing your database configuration and credentials to end-users if you create it via the front-end. Additionally, cloud functions allow you to trigger other side-effects, sanitise/format user data, etc.

  • @IvanKleshnin
    @IvanKleshnin 2 ปีที่แล้ว

    4:05 NEXT_PUBLIC_* vars are available in the browser - that's the whole purpose of prefixing them with NEXT_PUBLIC_.

  • @maxthestranger
    @maxthestranger 3 ปีที่แล้ว

    Nice

    • @JarrodWatts
      @JarrodWatts  3 ปีที่แล้ว

      Thanks Max! Appreciate it

  • @Archicuus
    @Archicuus 3 ปีที่แล้ว +1

    Hiya, When I set up the .env.local file and put 'process.env.VARIABLE_NAME'. I just get an error saying, the API key is invalid. All the credentials for me are correct. Can you help?

    • @JarrodWatts
      @JarrodWatts  3 ปีที่แล้ว

      Hey, sure I can try my best to help. Where are you seeing that error - when it's deployed, or just on your local environment?

    • @radhee9554
      @radhee9554 3 ปีที่แล้ว

      @@JarrodWatts on local environment

    • @JarrodWatts
      @JarrodWatts  3 ปีที่แล้ว

      Do you have NEXT_PUBLIC at the beginning of your environment variable name?

    • @radhee9554
      @radhee9554 3 ปีที่แล้ว +1

      @@JarrodWatts yes. Brother run npm again and it worked fine

    • @JarrodWatts
      @JarrodWatts  3 ปีที่แล้ว

      @@radhee9554 Cool - glad to hear you got it working

  • @LEDsellers
    @LEDsellers ปีที่แล้ว

    Is this tutorial still valid for next.js vs 13.1?

  • @SamyarBorder
    @SamyarBorder 3 ปีที่แล้ว

    THX

    • @JarrodWatts
      @JarrodWatts  3 ปีที่แล้ว +1

      No worries! Thanks for checking it out :)

    • @SamyarBorder
      @SamyarBorder 3 ปีที่แล้ว

      @@JarrodWatts ❤

  • @CesarSuareztrujillo
    @CesarSuareztrujillo 2 ปีที่แล้ว

    Nice tutorial but understand that you can’t deploy nextjs app into firebase hosting or is there a way? Alternative to publish the app?

    • @spencersablan8765
      @spencersablan8765 2 ปีที่แล้ว

      Hey! I there is a solution to deploy on firebase! Here's a couple articles that helped me out a ton:
      dev.to/rowaxl/what-i-struggled-with-next-js-using-firebase-hosting-and-enable-ssr-4e67
      medium.com/nerd-for-tech/lets-deploy-a-next-js-app-with-firebase-hosting-e070b3aecd04

  • @tomascarignano5002
    @tomascarignano5002 2 ปีที่แล้ว

    Hi Jarrod! I need your help big time mate. I recently tried to deploy my app to vercel, but I got an error. This error is because when I perform the deploy, vercel goes and looks at my /functions/ directory, tries to build, and cannot find a module in /functions/src/index.ts, because of course it's not present in /package.json
    Anyhow, appart from the obvious solution of git ignoring the functions directory, so that vercel wouldn't even look at it, I would like to know if there's a proper solution to this, and I think you might know one since I saw in your project's repo that you are, in fact, pushing the functions/ directory to github, and therefore deploying with vercel with it.
    Thanks so much in advance!

  • @DaWizardOfOz7
    @DaWizardOfOz7 ปีที่แล้ว

    firebase ui not working with React v18 :/

    • @kev11n_eleven
      @kev11n_eleven ปีที่แล้ว

      Can confirm. Won't even npm install.

  • @scorpion32
    @scorpion32 3 ปีที่แล้ว

    Shortest tutorial ever wow

    • @JarrodWatts
      @JarrodWatts  3 ปีที่แล้ว +1

      Would you prefer them to be longer? Or do you like this pace?

    • @JeanMarcSkopek
      @JeanMarcSkopek 2 ปีที่แล้ว

      @@JarrodWatts It's awesome! You cover a ton of ground really quickly. Makes it a lot of fun to watch the first time round, and then I can rewatch and pause as I go from step to step. About to try that now with this project :)

    • @JarrodWatts
      @JarrodWatts  2 ปีที่แล้ว +1

      Thanks! That's exactly what I'm hoping for :)

  • @cleverengineer2410
    @cleverengineer2410 ปีที่แล้ว +1

    Consider moving a bit slower next time however great video but I didn't enjoyed it to be honest

  • @Molla_Mahir
    @Molla_Mahir 5 หลายเดือนก่อน +1

    Pineapple doesn't belong on Pizza dislike

  • @LarsRyeJeppesen
    @LarsRyeJeppesen ปีที่แล้ว

    God, Hooks are so horrible

  • @matthewbeardsley7004
    @matthewbeardsley7004 2 ปีที่แล้ว

    using firebase.firestore().collection("votes") seems a bit cumbersome, what's the done thing...export this collection name from the clientApp.tsx file?

  • @Tyler-zb6ec
    @Tyler-zb6ec 2 ปีที่แล้ว +2

    V9 version of firebase.apps.length :
    import { getApps, initializeApp } from "firebase/app";
    if (getApps().length < 1) {
    initializeApp(firebaseConfig);
    // Initialize other firebase products here
    }
    ^ so you dont have to stack overflow lol