⚡ 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
Metadata
Release files for fastreact 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastreact-0.1.1.tar.gz | 18.3 kB | Without provenance | Details for fastreact-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastreact-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for fastreact-0.1.1-py3-none-any.whl |
Total release size: 36.0 kB
Release files / fastreact-0.1.1.tar.gz
| Download URL | fastreact-0.1.1.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
48023348a25caffadc44286a1c5a08ae34841b83a0043bd20f5bc6b301a06876
|
|
BLAKE2b-256 checksum How to use checksums |
546912b1d13c7965ce6d8697f9febf2e94775a3c52dec96453a6c8f2a178fd5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / fastreact-0.1.1-py3-none-any.whl
| Download URL | fastreact-0.1.1-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aedf9644ba11ef1ffd01a5990a67142bead277a6bed657ca99b4daaf02f3e8f0
|
|
BLAKE2b-256 checksum How to use checksums |
3abcf1c898033acb2347da5d41a9c1723a244e7f6026d90adf847681af737e2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Security for fastreact 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.