Skip to main content

Tool to create or patch FastAPI+Vue projects with integrated build/dev systems

Project description

fastapi-vue-setup

Tool to create or patch FastAPI project with a Vue frontend, with integrated build and development systems. The Python package will not need any JS runtime because it includes a prebuilt Vue frontend in it. For development (Vite and FastAPI auto reloads) and building the package one of npm, deno or bun is required (node is recommended due to bugs in deno and bun).

Features

  • No JavaScript: Your Python package can be installed and used without any JS runtime
  • Integrated build system: Vue frontend builds into Python package during uv build
  • Development server: Single command runs Vite + FastAPI with hot-reload
  • Optimized static serving: Caching, zstd compression and SPA support

Installation

Install uv, then:

uv tool install fastapi-vue-setup
fastapi-vue-setup --help

Or run directly:

uvx fastapi-vue-setup my-app

Usage

The script may be used to create an all new project folder or to patch or update an existing project to use this framework. It autodetects the project folder given and performs the appropriate actions.

Create a new project

fastapi-vue-setup my-app

This will:

  1. Run uv init my-app
  2. Run create-vue frontend (interactive - choose your Vue options)
  3. Patch the project with FastAPI integration
  4. Install dependencies via uv add

Patch an existing project

You should have your pyproject.toml at the current working directory, and Vue with its package.json under frontend/. If either one is missing, new applications will be initialised. Otherwise we only patch what can be patched without breaking your existing projects.

fastapi-vue-setup .

CLI Options

fastapi-vue-setup [project-dir] [options]

Options:
  --module-name NAME    Python module name (auto-detected from pyproject.toml)
  --dry-run             Preview changes without modifying files

Port Configuration

In development, you access the Vite dev server at http://localhost:5173. Vite proxies /api/* requests to FastAPI at port 5180. Ports and hosts of Vite and FastAPI are configurable by devserver.py arguments.

In production, FastAPI serves both the API and static files at http://localhost:5080. Configurable by host:port argument.

Vite Plugin Configuration

The fastapiVue() plugin in vite.config.ts accepts options to customize proxy behavior:

import fastapiVue from "./vite-plugin-fastapi.js";

export default defineConfig({
  plugins: [
    vue(),
    // Default: proxies only /api
    fastapiVue(),

    // Or specify custom paths to proxy to backend
    fastapiVue({ paths: ["/api", "/auth", "/ws"] }),
  ],
});

The plugin reads environment FASTAPI_VUE_BACKEND_URL (default: http://localhost:5180) to determine where to proxy requests. This is set automatically by devserver.py.

Project Structure

my-app/
├── frontend/                 # Vue application
│   ├── src/
│   ├── vite-plugin-fastapi.js
│   ├── vite.config.js
│   └── package.json
├── my_app/                   # Python module (files included in sdist)
│   ├── __init__.py
│   ├── __main__.py           # CLI entrypoint
│   ├── app.py                # FastAPI application
│   └── frontend-build/       # Built frontend (gitignored)
├── scripts/
│   ├── devserver.py          # CLI dev server (only in source tree)
│   └── fastapi-vue/
│       ├── build-frontend.py
│       └── util.py
└── pyproject.toml

The project directory tree looks roughly like this after project creation or patching. The script finds your existing fastpi app module and other files and patches them with minimal changes to enable the Vue-FastAPI interconnection. New Python and Vue projects are created automatically if none exist.

Development Workflow

# Start dev server (runs both Vite and FastAPI)
uv run scripts/devserver.py

# Build for production
uv build

# Run production server
uv run my-app

Frontend serving

Your FastAPI app will use fastapi-vue to serve the frontend files. Refer to that package's documentation for further configuration.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_vue_setup-0.2.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_vue_setup-0.2.1-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_vue_setup-0.2.1.tar.gz.

File metadata

  • Download URL: fastapi_vue_setup-0.2.1.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fastapi_vue_setup-0.2.1.tar.gz
Algorithm Hash digest
SHA256 8ea0bc92bd71bae70aba04fabaf72ef3f597ede5e80082a8eb9201ce70719c4f
MD5 c6f4faf376672a6b149d20535adb508b
BLAKE2b-256 6b25218108dae1d6e9c05707fff2074fb88305f7ad3d48223eadb453f487cbd2

See more details on using hashes here.

File details

Details for the file fastapi_vue_setup-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: fastapi_vue_setup-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fastapi_vue_setup-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1b91e7773786d77676f13cc3e19988a0f5facd4e78f58d891e9126e24fb9156c
MD5 ba4f3a275bdfd9547962f8f5288e7292
BLAKE2b-256 c8c6c214136ca48d24d5bea260379dc38a4f18720589df8b6aa3b989536f0d1f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page