---
title: "Next.js + FastAPI Starter"
description: "A monorepo with a Next.js frontend and a public FastAPI backend."
url: "https://vercel.com/templates/fast-api/next-js-fastapi-starter"
links:
  repository: "https://github.com/vercel/examples/tree/main/python/nextjs-fastapi"
  demo: "https://nextjs-fastapi-services.vercel.app/"
  deploy: "https://vercel.com/new/clone?demo-title=Next.js+%2B+FastAPI+Starter&demo-description=A+monorepo+with+a+Next.js+frontend+and+a+public+FastAPI+backend.&demo-url=https%3A%2F%2Fnextjs-fastapi-services.vercel.app%2F&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F2D3AQYGLAr6TqPKg3zxtYn%2F84c9c22aa66e3f68765b8c7c289e9f57%2Fnextjs-fastapi-services.png&project-name=Next.js+%2B+FastAPI+Starter&repository-name=next-js-fastapi-starter&repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fexamples%2Ftree%2Fmain%2Fpython%2Fnextjs-fastapi&from=templates&skippable-integrations=1"
---

# Next.js + FastAPI Starter

A monorepo with a Next.js frontend and a public FastAPI backend.

# Next.js + FastAPI

This example shows a monorepo using [Vercel Services](https://vercel.com/docs/services) with a Next.js frontend and a public FastAPI backend.

## Demo

https://nextjs-fastapi-services.vercel.app/

### How it works

The project is structured as a monorepo:
```
nextjs-fastapi/
├── backend/
├── frontend/
└── vercel.json
```

Services are configured in `vercel.json`:
```json
{
  "services": {
    "frontend": { "root": "frontend/", "framework": "nextjs" },
    "backend": { "root": "backend/", "entrypoint": "main:app" }
  },
  "rewrites": [
    {
      "source": "/svc/api/:path*",
      "destination": { "service": "backend" }
    },
    {
      "source": "/(.*)",
      "destination": { "service": "frontend" }
    }
  ]
}
```

Vercel will route requests to the `backend` service for URL with paths starting with `/svc/api/` and to `frontend` for all other URLs.

## Running Locally

```bash
vercel dev
```

Open `http://localhost:3000` and try:

- `/api/hello` (Next.js API route)
- `/svc/api/status` (FastAPI route)

## Learn More

- [Vercel Services](https://vercel.com/docs/services) - learn how services work on Vercel.
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [FastAPI Documentation](https://fastapi.tiangolo.com/) - learn about FastAPI features and API.

---

## Additional documentation

The [Vercel Knowledge Base](https://vercel.com/kb) contains guides and answers to common questions about Vercel, including deployment, framework configuration, domains, caching, and troubleshooting.
