How to use Firebase Auth with Astro

Sdílet
Vložit
  • čas přidán 27. 07. 2024
  • Join the early preview for my course! learnastro.dev
    Use FIREBASE_AUTH for $20 off.
    SAAS products like Firebase make authentication easy to implement. You need three items:
    1. A POST api endpoint
    2. Firebase auth
    3. Middleware to protect the routes
    🔗 Key Links 🔗
    - Github: github.com/coding-in-public/f...
    ---------------------------------------
    🔗 Additional Links 🔗
    - Firebase auth docs: firebase.google.com/docs/auth...
    - Astro actions docs: docs.astro.build/en/reference...
    - Astro middleware docs: docs.astro.build/en/guides/mi...
    ---------------------------------------
    ⏲️ Timestamps ⏲️
    0:00 Introduction
    1:43 New account form
    4:43 Add Firebase
    6:55 Setup Astro Actions
    9:20 New account POST
    18:00 Basic Middleware
    21:14 Login form/POST
    23:16 Logout form/POST
    23:35 Middleware route protection
    ---------------------------------------
    🌐 Connect With Me 🌐
    - Website: codinginpublic.dev
    - Blog: chrispennington.blog
    - Twitter: / cpenned
    - Patreon: / coding_in_public
    - Buy Me a Coffee: www.buymeacoffee.com/chrispen...
  • Jak na to + styl

Komentáře • 12

  • @friendly__drone9352
    @friendly__drone9352 Před měsícem +2

    I"m loving these Astro videos!

  • @oktubr3
    @oktubr3 Před měsícem

    You rock man! Thank you!!!

  • @Ryujin_001
    @Ryujin_001 Před 6 dny

    Bro after deploy to vercel auth.currentUser is null. Login signup and logout works well but never load the profile page because of the null currentUser

  • @SabahRahal-m2q
    @SabahRahal-m2q Před 25 dny

    Excellent video, I followed the steps and I have a problem, when I log in and enter from another session (any other device), the application understands as if I were logged in, any recommendations?

  • @andersonmarquesbsb
    @andersonmarquesbsb Před měsícem

    The best! ⬆⬆

  • @lostinthenarrativve
    @lostinthenarrativve Před měsícem +1

    Hey man, can you do supabase+Astro next? or lucia.

    • @emireles
      @emireles Před 5 dny

      In case you or someone else tries this. I encountered an issue when trying this with Supabase where the error would not pass down from the action since it comes wrapped in a AuthError class. To handle it just use the function isAuthApiError() to check if there is an error returned from the call and then you can throw an ActionError() to actually pass it down the action response when using the .safe() method in the action call.
      Hope this helps someone :)

  • @palockocz
    @palockocz Před měsícem

    Only output server can be used or also output hybrid?

    • @CodinginPublic
      @CodinginPublic  Před měsícem +1

      Also hybrid. Just make sure you mark routes you need SSR with prerender = false