Stack comparison

View architecture

This page compares two FastAPI-based setups that use the same data layer as flask-starter (models, services, Alembic migrations) but build pages differently. All three share the same DB schema and core features. They differ in where pages are rendered and which runtimes they need.

Three setups

Flask + Jinja

flask-starter

The server renders HTML with Jinja, and htmx swaps only the parts that need to change.

Browser

HTML forms, links

Flask

:5000

PostgreSQL

FastAPI + React(Vite)

A React app in the browser calls the FastAPI JSON API and builds the page.

React SPA

Vite :5173

FastAPI

:8000 /api/v1

PostgreSQL

FastAPI + Next.js

The Next.js server calls FastAPI and renders the page on the server. The browser talks only to the Next.js server.

Next.js

:3000 Server Components

FastAPI

:8000 /api/v1

PostgreSQL

Speed and weight

We made production builds of each template's base skeleton (with notices, banners and admin) on the same Windows PC and measured the public home page (November 2026, Node.js 24, pnpm 11). Actual load time (LCP) depends on the network and server, so we did not measure it. Instead, we compare how much is downloaded and the order of requests.

CSS and JS for the first page gzipped

Flask + Jinja
24.2 KB
FastAPI + React(Vite)
149.7 KB
FastAPI + Next.js
186.4 KB

JavaScript only uncompressed

Flask + Jinja
51.7 KB
FastAPI + React(Vite)
456.4 KB
FastAPI + Next.js
579.8 KB

Frontend packages node_modules

Flask + Jinja
None
FastAPI + React(Vite)
184 MB · 274 packages
FastAPI + Next.js
529 MB · 425 packages

Production build time same PC

Flask + Jinja
0.2s (CSS only)
FastAPI + React(Vite)
6s
FastAPI + Next.js
12s

Instead of node_modules, the Flask setup downloads a single Tailwind CSS executable (106 MB) once, the first time. Pinned backend Python packages: 20 for Flask and 16 for each FastAPI setup.

Until the first page appears

Flask + Jinja 2 steps

  1. 1Request HTML
  2. 2Show HTML with content

Scripts do not affect when the page appears. htmx only handles partial swaps after that.

FastAPI + React(Vite) 4 steps

  1. 1Request HTML (blank page)
  2. 2Download and run 150 KB of JS
  3. 3Call the API
  4. 4Show the page

Content appears only after the script runs and the API round trip completes.

FastAPI + Next.js 4 steps

  1. 1Request HTML
  2. 2Next.js server calls FastAPI
  3. 3Show HTML with content
  4. 4Buttons work after 186 KB of JS runs

Content appears right away, and interaction starts once the scripts arrive (hydration).

Layers shared by all three

Because the data layer code is the same, data and service rules built in one setup are easy to move to another.

Data layer

  • SQLAlchemy 2.1 models · pydantic schemas
  • Domain logic in services/, errors as ServiceError
  • Alembic migrations 0001 through 0004_notices_banners
  • PostgreSQL, time zone Asia/Seoul

Core features

  • Login sessions recorded in the DB · login attempt limits
  • Automatic admin account seeding
  • Notices (with attachments) · banners · admin pages
  • Refuses to start in production with insecure settings

Automation and rules

  • Project generation with scaffold.ps1 · scaffold.sh
  • GitHub Actions CI (including migration checks on postgres:16)
  • 5 AI task skills · AGENTS.md guidelines
  • Single KST time standard · one .env for settings

Side-by-side comparison

Aspect Flask + Jinja (flask-starter) FastAPI + React(Vite) FastAPI + Next.js
Page rendering Server (Jinja templates) Browser (React 19 SPA) Server (React Server Components) with Next.js 16 App Router
Browser sends requests to Flask server FastAPI /api/v1 (JSON) Next.js server only. The Next.js server calls FastAPI.
Reading and writing data View functions, redirect after form POST, partial swaps with htmx TanStack Query + axios, Zustand for global state Reads with fetch in Server Components, writes with Server Actions
Where auth state is kept Opaque DB session token sent in an httpOnly cookie Access JWT (15 min) in memory, refresh token in an httpOnly cookie Both access and refresh tokens in httpOnly cookies set by the Next.js server
Required runtimes Python 3.13 Python 3.13, Node.js 24, pnpm 11 Python 3.13, Node.js 24, pnpm 11
Frontend build None. Only CSS is built, with the Tailwind standalone CLI. Vite 8 + TypeScript 6 Next.js 16 + TypeScript 6
Tests pytest pytest (backend) + Vitest (frontend) pytest (backend) + Vitest (frontend)
Processes run during development Flask, 1 process (:5000) Vite dev server :5173 + FastAPI :8000 (Vite proxies /api) Next.js :3000 + FastAPI :8000
Production deployment 1 Python process (waitress or gunicorn) + HTTPS proxy Built static files + FastAPI process Node runtime (next start) + FastAPI process. Static hosting is not possible.

Difficulty and scope

Difficulty is based on how much a Python developer has to learn to start adapting the base skeleton.

Aspect Flask + Jinja FastAPI + React(Vite) FastAPI + Next.js
Difficulty Low Medium High
Languages Python, HTML(Jinja) Python, TypeScript Python, TypeScript
New concepts to learn Redirect after form POST, htmx attributes React state and effects, TanStack Query cache, token refresh flow React, the server/client component boundary, Server Actions, Next.js caching
Where to look for errors Just the Flask log Browser console + FastAPI log Next.js server log + browser console + FastAPI log
Search visibility (SEO) Favorable, since the server sends HTML with content Unfavorable, since the first HTML is empty. Pre-rendering has to be added separately. Includes server HTML plus robots.txt, sitemap.xml and OG image routes
Interactivity Forms, lists and partial updates Well suited to complex interactive UIs Server-rendered pages, with client components only where needed
Sharing the API with other clients The JSON API only covers health checks, so an API has to be built separately Shares FastAPI /api/v1 and its OpenAPI spec as is Shares FastAPI /api/v1 and its OpenAPI spec as is
Hosting 1 Python server Static files (CDN-ready) + API server Node server + API server

When each setup fits

Flask + Jinja

  • Form- and list-heavy services such as admin panels and business systems
  • Small teams that want to build and deploy with Python alone, without Node.js
  • Running the service as a single server process

FastAPI + React(Vite)

  • Interactive UIs with a lot of client state
  • Sharing the same JSON API with other clients such as mobile apps
  • Deploying the frontend as static files

FastAPI + Next.js

  • Using React components while rendering pages on the server
  • Keeping auth tokens and internal API URLs out of browser scripts
  • Teams that can operate a Node runtime
Back to top