Skip to content
VercelLogotypeVercelLogotype
LoginSign Up

Next.js Flask Starter

Simple Next.js boilerplate that uses Flask as the API backend.

DeployView Demo

Next.js Flask Starter

Simple Next.js boilerplate that uses Flask as the API backend.


Introduction

This is a hybrid Next.js + Python app that uses Next.js as the frontend and Flask as the API backend. One great use case of this is to write Next.js apps that use Python AI libraries on the backend.

How It Works

This project uses Vercel Services to deploy a Next.js frontend and a Flask backend as part of a single Vercel project. Services are configured in vercel.json using the experimentalServices key:

  • Frontend — Next.js, mounted at /
  • Backend — Flask, mounted at /api/python

Vercel automatically routes requests to the correct service based on the URL path prefix. It also automatically injects environment variables based on the service name to easily route between services. To make requests to the Python backend service and keep preview environments in sync without having to hard-code urls, NEXT_PUBLIC_BACKEND_URL is automatically set.

Demo

https://nextjs-flask-starter.vercel.app/

Deploy Your Own

You can clone & deploy it to Vercel with one click:

Developing Locally

You can clone & create this repo with the following command

npx create-next-app nextjs-flask --example "https://github.com/vercel/examples/tree/main/python/nextjs-flask"

Getting Started

First, install the dependencies:

npm install
# or
yarn
# or
pnpm install

Then, run both services locally:

vercel dev -L

The -L flag runs all services together locally without authenticating with the Vercel Cloud. Open http://localhost:3000 with your browser to see the result.

Learn More

  • Vercel Services - learn how services work on Vercel.
  • Next.js Documentation - learn about Next.js features and API.
  • Flask Documentation - learn about Flask features and API.
GitHub
Ownervercel
Repositoryexamples
LicenseView License
Use Cases
Starter
Backend
Stack
Next.js
Flask
Tailwind

Related Templates

Flask Alt Text Generator

A flask API that generates a description for any image.
Flask Alt Text Generator thumbnail

Python Hello World

Use Python on Vercel with Serverless Functions using the Python Runtime.
Python Hello World thumbnail

Flask Hello World

Use Flask 3 on Vercel with Serverless Functions using the Python Runtime.
Flask Hello World thumbnail

Agent Stack

  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • EveNew
  • ConnectNew

Core Platform

  • CI/CD
  • Content Delivery
  • Fluid Compute
  • Observability

Security

  • Platform Security
  • WAF
  • Bot Management
  • Bot ID

Tools

  • Vercel DropNew
  • Vercel Agent
  • Vercel PluginNew
  • Next.js
  • Domains
  • v0

Frameworks

  • Nuxt
  • SvelteKit
  • Nitro
  • Turborepo
  • Tanstack Start
  • FastAPI
  • xmcp
  • All frameworks

SDKs

  • Vercel SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDKNew
  • Queues SDKNew
  • Streamdown

Build

  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
  • Platform Engineers
  • Design Engineers

Learn

  • Docs
  • Blog
  • Changelog
  • Knowledge Base
  • Academy
  • Articles
  • Community

Explore

  • Customers
  • Marketplace
  • Templates
  • Partner Finder
  • Vercel + AWS

Company

  • About
  • Careers
  • Press
  • Events
  • Startups
  • Shipped on Vercel
  • Open Source Program
  • Enterprise
  • Pricing
  • Help

Legal & Trust

  • Privacy Policy
  • Terms of Service
  • Cookie Policy
  • DPA
  • Acceptable Use Policy
  • Legal (all documents)
  • Trust Center
  • Status

Social

  • GitHub
  • X
  • LinkedIn
  • YouTube
  • Instagram
  • VercelVercel
Agent Stack
  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • Eve
Core Platform
  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • CI/CD
Tools
  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • Domains
  • v0
Learn
  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base
Build
  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
Explore
  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community
EnterprisePricing
Contact
Log InSign Up
Dashboard

Products

Agent Stack

  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • Eve

Core Platform

  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • CI/CD

Tools

  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • Domains
  • v0
Resources

Learn

  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base

Build

  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce

Explore

  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community
Enterprise
Pricing
Sign UpLog In
Contact
DeployView Demo

Loading status…

Select a display theme: