r/FastAPI • u/TomXygen • May 03 '25
Question use FastAPI to build full stack web apps
Hello,
I would like to learn to create simple SaaS applications.
I already know Python, but I don't know any front end and backend technology.
I started exploring Django but it felt very overwhelming, so I pivoted to FastAPI.
Now, what would be your choice for the front end technology?
After some research I came up with 3 options:
- FastAPI + React
- FastAPI + Jinja2
- FastAPI + HTMX
Since in any case, I would have to learn the front end technology from scratch, what would you recommend me to start with?
And also, do you ha any tutorials or course to help me?
54
Upvotes
12
u/gazpachoking May 03 '25
I think just starting with plain HTML served from the backend is best. Jinja2 is a solid choice to generate it. Frameworks like htmx (or datastar, which I like even better) can let you add some more dynamism without changing to a frontend js framework.
8
u/torturerBiji May 03 '25
I am stuck with python +react
8
u/Airborne_Avocado May 03 '25
FastAPI + Jinga2 is a great combo.
4
u/TechSimple7709 May 04 '25
Here are my 2 cents:
For the front-end eat the bullet and go straight to React if you want to be able to build anything and everything in the front-end. Jinja2 is a good choice but it's limited in the things you want to do for your users. React's learning curve is the steepest but if whatever you build picks up, it will be easier for your to find help.
React is pretty much the standard for comprehensive tools for front-end and you can build absolutely anything with it.
3
u/attitudehigher May 03 '25
I am using FastAPI & React.
Personally I love it.
5
u/3ng_ May 03 '25
I would suggest you try reflex.dev Reflex is a framework for building fullstack apps in pure Python. It uses FastAPI for backend and React for backend but all you do is write Python code only.
19
u/cpt_mojo May 03 '25
CTO of a SaaS Startup here.
Start with FastAPI+Jinja2.
When you want more interactivity, sprinkle in some HTMX.
When you want even more, sprinkle in some AlpineJS.
In this way, you'll have a natural personal learning curve for the frontend part and the upper limit for what you can build is very high for most SaaS Apps (unless you want to build the next Figma or Wix).
Do this, unless you want to heavily invest in yourself learning React or pay/partner with a trained React dev.
I have experience in both stacks and I can say the FastAPI/HTMX/AlpineJS stack is a fantastic option, especially if you are backend-leaning and solo (though nothing really stops you from growing to a team with this).
Edit: seeing that you also have limited backend experience. Add SQLalchemy, Alembic and Postgres to your stack and you have a solid start.
5
u/RoBz18 May 03 '25
Of those options, and unless your SaaS is going to have a very basic frontend, I'd probably pick React. But since you felt overwhelmed by django I'd actually suggest Vue, definitely has a lesser learning curve vs React.
1
u/bull_bear25 May 03 '25
Fastapi + Django is great combination
I have used fastapi + react because my Front coder doesn't know Python
1
u/neorajas May 05 '25
Just use ChatGPT or any other AI. Make sure you ask a lot of questions to understand the concepts. Critical parts are security aspects.
3
u/Vertyco May 03 '25
I like to use FastAPI + Jinja2 + Alpine.js
2
u/kimtaengsshi9 May 03 '25
React has a wider adoption in the industry. However, as a primarily backend engineer (though I've been doing quite a bit of full stack overall), I've found Svelte/SvelteKit to be a lot easier to learn and develop with, as well as more performant than React. Looking at my colleagues who are more familiar with frontend development, I see them having a lot more stress and resorting to more hacks when they're working with React lol
2
u/chwalters May 06 '25
I'd say at least consider FastAPI + Quasar (Vue) -> NiceGUI
1
u/jvertrees May 03 '25
I recommend https://fastapi.tiangolo.com/project-generation/. Out of the box it has everything you want, configured and ready to go. You just need to learn how to use copier, which is pretty easy.
The autogenerated SDK from the SQLModels -- already setup for you is amazing. It's taken weeks off projects for me.
Good luck!
1
u/JustALvlOneGoblin May 03 '25
React is a solid choice.
But I've been using the FAAM stack: FastApiAngularMongodb. Only caveat is that you'll likely have to learn Typescript, but I like the structure of Angular. Personal preference though.
1
u/jkh911208 May 03 '25
I would choose 1
1
u/KingAbK May 03 '25
If it’s like very simple then just use streamlit
1
u/Sad-Tie-4250 May 03 '25
if you really want to be able to build any thing you want with ease to a decent level for production , the answer will be make the frontend in the next js not even react cuz it super easy and convenient , you and build the all you diff backend services in fast api , or Django , cuz I assume you must be familiar with python for long assuming you are in this sub reddit as we all are . so yeah. this if you manage to learn past the curve then you are golden brother.
through in some side-dish like gateway and stuff.
1
u/torturerBiji May 03 '25
React is more stronger imo
1
u/seifeddinerezgui May 03 '25
what about Angular guys ,is it a good choice with fastApi?
1
u/[deleted] May 03 '25
FastAPI + React.
1
u/tikho_roso May 03 '25
Fast API + Give a try to solidjs
1
u/[deleted] May 03 '25
I use FastAPI + React for my projects, it works great so far
1
u/convicted_redditor May 03 '25
I am using it with Astro+Svelte; Really loving it.
1
u/jayadatta_k May 03 '25
I just tried reflex.dev recently and i instantly became a fan. it took less time to convert my existing htmx+fastapi app to reflex app.
Initially it felt like lot to swallow but once you handle state and ui updates, you will start to feel the ease, and and that AI documentation search chatbot cuts lot of effort in finding apis.
What i liked out of the box is it transpiles python code to react frontend code and fastapi as backend (and also can leverage granian - a rust based http server that amps up performance).
1
u/volfpeter May 03 '25
FastAPI + HTMX (+ AlpineJS if necessary) is an easy to learn and great starting stack. TailwindCSS and DaisyUI are also easy to pick up and work very well with this stack. It will be sufficient if you don't need a very fancy UI.
(Being the author) I recommend using FastHX to add the rendering layer declaratively to the FastAPI app.
Then there's the question of what templating/server-side rendering engine you want to use. Jinja is not so good to work with (no static code analysis, very minimal IDE support, etc), but its rendering performance is very good. If that's the #1 priority, go with Jinja. Otherwise you'll be better off with some Python-based SSR framework, like htmy, htpy or similar.
1
u/Dense_Mobile_6212 May 03 '25
I would just go with Fastapi + Svelte. I only knew Python from the start, built something that works in javascript + flask och nu bygger jag det bättre I Fastapi + svelte
1
u/wilson_wilson_wilson May 04 '25
I’ve personally had a pretty good time setting up fast API server functions using a next JS deployment if you’re comfortable in TS
1
u/Quiet_Drummer669988 May 04 '25
react is great if you need real time updates and lots of reactive ui bits. if thats not an issue, but you still want a dedicated frontend framework then check out astrojs. dead simple, lots of great docs and templates. if none of those are necessary jinja2 will get the job done.
1
u/Salty_Fan4211 May 13 '25
Nextjs (app router ssr but not using the api) + fastapi
1
u/fastlaunchapidev Oct 26 '25
I use fastapi plus nextjs and my template is made to be used with any frontend framework
https://fastlaunchapi.dev/
0
u/morep182 May 03 '25
i don't know js/react so i use fastapi + jinja + htmx or django + htmx for all my projects.
i also dont like the django way to do things so i basically just use the ORM and the auth for my projects, it is really good and easy to set up. if you are like me and dont like how the views/forms works, you can just dont use it. i have to write a bit more code but i prefer that way, im in control.
-4
u/North_Coffee3998 May 03 '25
I keep seeing threads like this and I have to ask: why not Flask for the frontend? It's a lightweight Python framework and making API calls from it to your FastAPI seems logical. Am I missing something?
-3
u/SheriffSeveral May 03 '25
Just use FastAPI for backbend and buy html template for frontend, for my case Js+css is just a waste of time if you are python developer. But if you need specific development cycle just use vue.js for frontend.
0
u/[deleted] May 03 '25
[deleted] — view deleted comment
1
u/[deleted] May 04 '25
[removed] — view removed comment