r/FastAPI • • Aug 29 '24

Question fastapi auth in production

I'm developing a web app with nextjs frontend and fastapi backend. Currently I'm using fastapi auth for testing end to end flow of the app. I'm trying to figure out if fastapi jwt based auth can be used in production. Is it a good practice to use fastapi auth in production system? How does it compare with managed auth services like Nextauth, auth0 or clerk? What would you recommend?

Thanks!

15 Upvotes

18 comments sorted by

View all comments

Show parent comment

1

u/5dots Aug 29 '24 edited Aug 29 '24

Thanks!

Do I need to use both next-auth and fastapi auth?

Can it be done just with fastapi jwt auth in the backend? When user logs in, the username/password is sent to backend fastapi auth, it checks if the user exists and the password and provides a JWT token to the client. Client stores it in the localstorage. What's the issue with this approach?

2

u/aliparpar Aug 29 '24

Frontend is better to use next-auth. Backend doesn’t need FastAPI-auth. You can implement jwt without external libraries like FastAPI-auth. Gives you more control over auth.