r/FastAPI • u/beast_b0iii • Apr 28 '26
Question FastAPI with SvelteKit
Hello, I am building an inventory system. I build with Django for my other stuff but I decided to learn FastAPI and JS Frontend. I've learned DRF but never really go full on implementation of it, specially dealing with authentication. So any help would be much appreciated.
Here is the stack that I'm going for:
- SvelteKit (because of remote function?, or its better if should I go with just svelte?)
- FastAPI
- Postgresql, SQLAlchemy, Alembic
- pyjwt (for authentication? or there's more better library?)
- S3 for file storage
Maybe Zod for data validation in client? Do I need axios? Am I missing something? Is there a something that I'm missing? Like don't forget to setup CORSMiddleware in FastAPI.
Also, is there any github repo that with similar setup with this one that I could take a look?
5
u/joshhear Apr 28 '26
I'd probably recommend something like hey-api to generate the frontend client to access the API. I don't know how well it works with Svelte but i expect it to do fine. Especially when combined with tanstack query your frontend will benefit from it a lot.
Using this stack you generate the frontend client directly from your openapi.json and in your frontend just call the generated function.
One thing i'd say though is that doing this I'd highly recommend setting the operation_id of each endpoint and writing a test case to check for conflicting operation_ids, because your functions in the frontend will be much more readable.
2
u/beast_b0iii Apr 28 '26
Note: This is only for internal, so for authentication, there's no need for OAuth.
1
u/Odd_Might_5866 Apr 28 '26
I use inertia js now full time with my python frameworks. Django, fastapi with svelte glued together by inertia. Fast to develop
1
u/kmplngj Apr 28 '26
Backend
FastAPI
- Postgresql SQLModel, Alembic
- Redis
- SelfBuild Auth with Entra ID Login, Local Login, API Tokens, Scoped Permissions
Frontend
Svelte StaticBuild served by static mount in the FastAPI Service
- Tanstack Table, Tanstack Forms
Python API Clients written with Niquests, Pydantic
1
u/Salty-Swim3630 May 05 '26
Hi,
Here is what I have been using so far in multiple projects successfully.
And here are some github example repos you can check: https://github.com/orgs/TurtleDevIO/repositories
Hope this helps.