Full stack FastAPI template Next.js

Dashboard page Full stack FastAPI template Next.js

Overview

Next.js v16 fork of the official fastapi/full-stack-fastapi-template template. Server components, server actions, HttpOnly cookie auth, Github login, ShadcnUI with TailwindCSS v4, Docker and Vercel production.

Goals

Integrate a solid, up-to-date SSR FastAPI, Next.js template to reuse as a starting point for future projects.

Tech stack

Credits

Features

Implementation details

I needed a solid FastAPI, Next.js starter as a base for future projects. I reviewed all the examples I could find and discovered that the official fastapi/full-stack-fastapi-template was the closest to what I wanted. However, it still wasn’t a complete match, it relied entirely on client-side rendering using TanStack Router and Chakra UI, and handled authorization via tokens stored in localStorage.

I decided to fully customize it to fit my needs and preferences, so I rewrote the frontend from scratch using Next.js v16 with Server Components and Server Actions, along with ShadcnUI, Tailwind CSS v4, and a Turborepo monorepo setup. To enable SSR, I modified the backend to use an HttpOnly authentication cookie.

Additionally, I proxied all FastAPI endpoints through the Next.js server (via API routes and Server Actions), which significantly simplified and hardened the cookie setting/unsetting logic. This approach also enables hosting the backend and frontend on separate domains without requiring an external reverse proxy (e.g., Traefik, Nginx) or URL rewrites (e.g., Vercel).

I also added Github OAuth login using Authlib, since I plan to use it in my next project.

The repository also includes Github Actions workflows to build, push, and deploy the backend and frontend as separate Docker images.

The Next.js app is designed to rely exclusively on runtime environment variables, enabling reusable builds and Docker images that can run in any environment and under any domain.

Finally, I included Vercel configuration files and a “Deploy button” to make the project eligible for submission to the official Vercel templates gallery.

Lessons learned

I documented my findings in detail in the following blog posts: