DEV Community

Cover image for How to use Firebase Authentication in Next.js 13, Server Side with Admin SDK

How to use Firebase Authentication in Next.js 13, Server Side with Admin SDK

Geiel Peguero on May 27, 2023

I'm new to this world of Full Stack Frameworks like Next.js, SvelteKit, Remix... But I know all the advantages it has so I wanted to use it to crea...
Collapse
 
victorfu profile image
Victor Fu

Using await fetch("/api/login") in the middleware doesn't work. It will throw an error: Failed to parse URL. I found a working solution for my case. FYI.

await fetch(`${request.nextUrl.origin}/api/login`)
Enter fullscreen mode Exit fullscreen mode
Collapse
 
estevanulian profile image
Estevan Ulian

Thanks for the tip.

Collapse
 
ibrahimraimi profile image
Ibrahim Raimi

Great article, Geiel. I love the fact that you included screenshots for better understanding.

Collapse
 
geiel profile image
Geiel Peguero

Thank you Ibrahim

Collapse
 
marcellintacite profile image
Aksanti Bahiga tacite

Thank you for the article, but i would like to know , how do i get current user information?

Collapse
 
3akare profile image
David Bakare

auth.currentUser.[information]

Collapse
 
maxwissink profile image
maxwissink

When deploying this to firebase, i get an 500 internal server error, can you confirm that this solution works on your end? thanks

Collapse
 
aayman997 profile image
Ahmed Ayman

Yes same for me I get an error
The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services

Collapse
 
itssidhere profile image
Sapien

Great Article!

Collapse
 
3akare profile image
David Bakare

You are the best!

Collapse
 
zainuldin profile image
Zain_ul_din

How to retrieve user credentials on the client side once the user login and reloads the page?

Collapse
 
drnyt profile image
Shehryar

Just what I needed, amazing article!

Collapse
 
jikkeee profile image
jikkeee

thanks man

Collapse
 
estevanulian profile image
Estevan Ulian

It's a great article. Thank you.

Collapse
 
vic_ble profile image
victordelva

Thank you! It was helpful!

Collapse
 
kevin_tom_f2ca63e0b302ac1 profile image
Kevin Tom

Great article. I followed it but midway lost track.
Ended up using firebase-nextjs package. It was much easier to setup.

Collapse
 
vikas62502 profile image
Vikas Yadav

great documentation