FastAPI + React unified stack — zero config, one server, Python tracebacks in browser
Project description
⚡ FastReact
FastAPI + React = One Unified Stack
Zero config. One server. Python tracebacks in your browser.
What is FastReact?
FastReact is a Python library that bridges FastAPI and React into a single seamless stack.
- 🐍 FastAPI thinks it's serving Jinja templates — it's actually serving React
- ⚡ React thinks it's a normal Vite app — it's tunneled through FastAPI
- 🔴 Python errors appear as beautiful overlays in the browser (just like React's own error screen)
- 🔒 Python is the gatekeeper — React can only visit routes you register
- 🚀 One
uvicorninstance serves everything — in dev AND production
Install
# FastAPI + React
pip install fastreact
# Flask + React
pip install fastreact[flask]
Quick Start
# 1. Scaffold React inside your FastAPI project
fastreact create frontend
# 2. Start both servers together with live request monitor
fastreact dev main:app --reload --call
# 3. Build for production
cd frontend && npm run build
uvicorn main:app --host 0.0.0.0 --port 8000
Usage
# main.py
from fastreact import FastReact
app = FastReact()
# React page routes — /api/ prefix — browser only
# Postman/curl → 405 Not Allowed
@app.get("/api/")
def home(): pass
@app.get("/api/users")
def users_page(): pass
# Normal data routes — everyone can call
@app.get("/users")
def get_users():
return {"users": ["Alice", "Bob"]}
uvicorn main:app --reload
Flask Support
from fastreact import FlaskReact
app = FlaskReact()
@app.route("/api/users")
def users_page(): pass
@app.route("/users")
def get_users():
return {"users": ["Alice", "Bob"]}
if __name__ == "__main__":
app.run()
Routing Rules
| Route | Browser | Postman/curl |
|---|---|---|
/api/users (react prefix) |
✅ React renders | ❌ 405 Not Allowed |
/users (normal route) |
✅ JSON | ✅ JSON |
/api/unknown (unregistered) |
❌ 404 | ❌ 404 |
Custom prefix
app = FastReact(react_prefix="ui") # /ui/... becomes React routes
CLI
fastreact create <n> Scaffold a new React (Vite) app
fastreact dev <file:app> [opts] Start FastAPI + React dev servers together
--reload Auto-restart on file save
--port <number> Port number default: 8000
--host <address> Host address default: 127.0.0.1
--call Live HTTP request monitor
Traceback Overlay
Python errors render as a beautiful browser overlay instead of JSON:
🔴 FastAPI Traceback — AttributeError
'NoneType' object has no attribute 'id'
File main.py, line 24, in get_user
return user.id
^^^^^^^^^^^^^^
Roadmap
- FastAPI + React unified stack
- Flask + React support
- CLI dev mode — one command starts everything
- Live request monitor (
--call) - Python traceback overlay in browser
- Route protection — browser-only React routes
- Auto path normalization
-
--globalname— instant public URL via SSH tunnel (v0.2.0)
Documentation
| Guide | Description |
|---|---|
| USAGE.md | Full usage guide with all examples |
| PUBLISH.md | How to publish to PyPI |
Author
Mohammad Ramiz
- 🌐 mohammadramiz.in
- 🐙 GitHub
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastreact-0.1.1.tar.gz.
File metadata
- Download URL: fastreact-0.1.1.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48023348a25caffadc44286a1c5a08ae34841b83a0043bd20f5bc6b301a06876
|
|
| MD5 |
58544f12e222dc6fa5fb2afb4e5743bb
|
|
| BLAKE2b-256 |
546912b1d13c7965ce6d8697f9febf2e94775a3c52dec96453a6c8f2a178fd5b
|
File details
Details for the file fastreact-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fastreact-0.1.1-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aedf9644ba11ef1ffd01a5990a67142bead277a6bed657ca99b4daaf02f3e8f0
|
|
| MD5 |
89d2fe82e55b7c024d2b73c72a5ac06a
|
|
| BLAKE2b-256 |
3abcf1c898033acb2347da5d41a9c1723a244e7f6026d90adf847681af737e2c
|