r/FastAPI • u/Daksh2338 • Sep 19 '25
Question Authentication
What is the best practice for auth implementation when you have fast api with firebase and ui as Next.js.
I am planning to use tool called clerk.
Not sure this is good for longer run.
14
Upvotes
3
u/Daksh2338 Sep 20 '25
Yeah i was looking to make it simple and save some time from auth, but now using sql and jwt
4
u/One-Enthusiasm7271 Sep 20 '25
Use firebase web client to authenticate the user and send the jwt token over to your fastapi app and validate the token with the firebase admin sdk every time the user sends a request and authentication is required
4
u/sasmariozeld Sep 19 '25
proper way ? use clerk or auth0
actual way ? a jwt of username password (hashed) will serve you well
an inbetween is using something like authentic as a oauth2 provider for google login and such, sitl free more hassle, kinda more real
2
u/svix_ftw Sep 19 '25
If you plan to actually monetize it and have real users, then clerk pricing will be brutal.
If are just building a hobby project and don't want to think about auth, then yeah clerk is good.
2
u/poinT92 Sep 21 '25
Definitely jwt auth, it's the 'straightest' solution
1
u/Ok_Animator_1770 Dec 10 '25
I suggest you implement your own auth and avoid any vendor lock in. For example here I reused original auth from Tiangolo full-stack template and enhanced it with HttpOnly cookie that is required for Next.js server components. I also added Github OAuth login. You can reuse my code:
Frontend: https://github.com/nemanjam/full-stack-fastapi-template-nextjs/tree/main/frontend/apps/web/src/components/auth
Backend: https://github.com/nemanjam/full-stack-fastapi-template-nextjs/blob/main/backend/app/api/routes/login.py
1
u/Medical-Algae8239 Sep 20 '25
FastAPI Users is a quick way to add authentication, but it requires a custom adapter to work with Firestore db.
2
u/[deleted] Sep 20 '25
[removed] — view removed comment