Setup
Setting up our development environment and generating a new project to get our application running.
Install tooling
We will use Visual Studio Code as our editor, uv for Python and fnm for Node.js. If you already have a preferred editor or a recent Node installation, feel free to adapt the instructions to your setup.
Open Terminal from Start Menu and install the tools using the following command:
winget install --scope user --exact astral-sh.uv Schniz.fnm Microsoft.VisualStudioCode
Install Homebrew if you donβt already have it, following the instructions on its website. Then run:
brew install uv fnm visual-studio-code
Install the following tools according to the instructions for your operating system:
On a Chromebook, enable the Linux development environment and install the Linux versions of these tools. See also the VS Code guide for Chromebooks.
Creating the project
Once the tools are installed, close your system terminal and launch Visual Studio Code from the start menu (Continue without Signing In). If you already had VS Code running, you may need to restart it to pick up the newly installed tools.
Select Open Folder, and create and open a new folder named poll-box in a location where you would like to keep your projects (e.g. Documents or Dev). After opening poll-box, choose to Trust this folder.
Select Terminal β New Terminal from the menu bar (click three dots if the menu isnβt visible). This opens a terminal within the editor, already positioned in our project folder.
If you are low on screen space, close β the Chat panel on the right, and the π Explorer panel on the left. You may also scale the interface by Ctrl+Plus/Minus as needed. Make sure the Terminal can fit about 20 lines at least.
Bringing Vue and FastAPI together
Vue and FastAPI serve quite different purposes. Vue runs in the browser, where it renders our interface and responds to user interactions. FastAPI runs on the server, where we implement operations that clients need to perform and manage data shared between them.
We could set up each independently, but we would then need to configure how the browser reaches our backend during development, how to run the two development servers together, and how to distribute the built frontend with our Python application for production.
fastapi-vue-setup takes care of this dance. It generates a Python project with a FastAPI application, uses Vueβs own create-vue tool to generate the frontend, and configures the connection between the two. It also provides a development server script and integrates the frontend build into the Python packaging process.
Run the following command in our terminal:
uvx fastapi-vue-setup .
uvx runs the setup tool without requiring us to install it permanently. The dot (.) refers to the current directory. Alternatively, we could provide a folder name to create a new project directory. Note that the folder name becomes the project name.
Python and Node.js are installed automatically using uv and fnm as needed.
The setup tool launches Vueβs interactive project generator. Enable Vue Router for navigation and Pinia for state management, and otherwise accept the defaults. For this tutorial we will use TypeScript and the Vue example code (do not skip to a blank Vue project). You may customize the choices if you know you want something else.
The example gives us components, assets, a layout and a stylesheet to start with. In the next part, we will turn this interface into our own application.
This is not a one-time generator. If you ever need to upgrade or change fastapi-vue settings such as default port numbers, just run
uvx fastapi-vue-setup .again. It can also integrate existing Vue and FastAPI projects that follow the directory structure shown below.
Exploring the project
Once the setup finishes, the generated files appear in the π Explorer on the left side of VS Code. These are the files and directories we will work with most often:
poll-box/
βββ backend/poll_box/
β βββ app.py # FastAPI application
β βββ __main__.py # The poll-box command
βββ frontend/
β βββ src/
β β βββ main.ts # Vue, Vue Router and Pinia initialization
β β βββ App.vue # Root Vue component
β β βββ components/ # Other Vue components
β β βββ router/ # URL routes and navigation
β β βββ stores/ # Pinia stores
β βββ vite.config.ts # Frontend development and build settings
β βββ package.json # Frontend dependencies and commands
βββ scripts/devserver.py # Starts both development servers
βββ pyproject.toml # Python project configuration
The frontend and backend have their own source files and dependency configurations, but they belong to the same application. Both are ordinary Vue and FastAPI projects, and we will be working with their usual components, stores and endpoints.
Open backend/poll_box/app.py and frontend/src/App.vue in the editor. If VS Code suggests installing extensions for Python or Vue, accept these to enable language-specific features such as code completion and error highlighting. TypeScript support is already built into VS Code. Close the extension pages it opened, as we donβt need them, but make sure you have those two files open.
Running the application during development
The generated project includes the fastapi-vue development server, which runs both the frontend and backend and automatically reloads them whenever we modify our code files. There is no need to manually restart or rebuild the application.
Start the server in the terminal:
uv run scripts/devserver.py
On the first run, the development server also installs the frontend dependencies, which will take a moment. Wait until Vite says it is ready, and open the localhost:3100 link it shows (Ctrl+Click on Windows and Linux, β+Click on Mac). This opens the application in the integrated browser.
You should see the generated Vue welcome page, with the heading You did it!, and below it a FastAPI: β indicator for successful connection with the backend.
Drag the browser tab to the right edge of the editor area so that we can see our source code and the running application side by side. Keep the terminal visible below them to see messages from the development server.
If you are using an external browser, arrange your editor and browser windows side by side instead. This lets us see the effects of our changes without switching between windows. Play around with the app. You can modify App.vue or components/HelloWorld.app and see how the page changes whenever you save the file.
Before continuing, make sure the generated page loads and the FastAPI indicator is green. If something is not working, check the development server output in the terminal. If you are in a hurry, you can skip the optional sections below.
Optional: Check the backend
We can already see the frontend running, but how do we know it is actually communicating with FastAPI?
Open http://localhost:3200/api/health in another browser tab. During development, the backend runs on a separate port (3200) and returns a small JSON object:
{"status":"ok"}
Now try http://localhost:3100/api/health. We get the same response, even though port 3100 belongs to our frontend development server.
This is because the setup tool has configured Vite to forward requests under /api/ to our backend. The frontend can simply use an address such as /api/health without having to know where the backend is running. These paths can be modified in frontend/vite.config.ts.
The generated Vue component uses this mechanism to check that the backend is reachable, as you can also see in the access log printed in the terminal.
For production, the frontend and API are served together from a single Python application. We will cover this in Deployment.
Optional: Automated milestone checks
For those who would like to verify their progress automatically, we provide a set of ready-made end-to-end tests. They use Playwright to open our application in a browser and check that it behaves as expected at each milestone. No knowledge of Playwright is required.
If you would like to use them, download the tutorial test files and extract the archive into the poll-box/ directory. It adds playwright.config.ts and the milestone specifications under frontend/e2e/.
Keep the development server running and select Terminal β New Terminal or the οΌ button above the terminal to open another terminal, keeping the devserver on the original one. Install the testing suite:
cd frontend
npm install -D @playwright/test
npx playwright install chromium
Run the supplied Part 1 checks from frontend/:
npx playwright test e2e/01-setup.spec.ts
Both checks should pass: the example page connects successfully to FastAPI, and the health endpoint returns the expected response. The browser check also saves light- and dark-mode screenshots under frontend/test-results/.
Each part of the tutorial has its own numbered spec file, e.g.
e2e/02-vue.spec.ts. Keep this terminal available for running the checks as you progress. They are entirely optional, and we wonβt mention testing again.
Where we are now
We now have a working Vue application connected to a FastAPI backend.
Leave the development server running. In the next part, we will turn the generated Vue example into Poll Box.