Simple Nuxt.js boilerplate that uses FastAPI as the API backend.
This is a hybrid Nuxt.js + Python app that uses Nuxt.js as the frontend and FastAPI as the API backend. One great use case of this is to write Nuxt.js apps that use Python AI libraries on the backend.
The Python/FastAPI server is mapped into to Nuxt.js app under /api/
.
The server API of Nuxt3 has been relocated to /backend/
to make it compatible with the Vercel API routes.
This is implemented using nuxt.config.js
rewrites to map any request to /api/:path*
to the FastAPI API, which is hosted in the /api
folder.
On localhost, the rewrite will be made to the 127.0.0.1:8000
port, which is where the FastAPI server is running.
In production, the FastAPI server is hosted as Python serverless functions on Vercel.
https://nuxtjs-fastapi-starter.vercel.app/
You can clone & deploy it to Vercel with one click:
You can clone & create this repo with the following command
npx create-nuxt-app nuxtjs-fastapi --example "https://github.com/tutorfx/nuxtjs-fastapi"
First, install the dependencies:
npm install
# or
yarn
# or
pnpm install
Then, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
Open https://localhost:3000 with your browser to see the result.
The FastApi server will be running on https://127.0.0.1:8000 – feel free to change the port in package.json
(you'll also need to update it in nuxt.config.js
).
To learn more about Nuxt.js, take a look at the following resources:
- Nuxt.js Documentation - learn about Nuxt.js features and API.
- FastAPI Documentation - learn about FastAPI features and API.
You can check out the Nuxt.js GitHub repository - your feedback and contributions are welcome!