Skip to main content

Full-stack React + Python with zero configuration. Build modern React apps with FastAPI, Bun, Inertia.js, and Tailwind CSS.

Project description

PyReact Start

Full-stack React + Python with zero configuration.

Build modern React applications powered by FastAPI, Bun, Inertia.js, and Tailwind CSS — all from a single pip install.

Motivation

When building React apps with Python, you're stuck with tough choices:

  • SPA-only: You have an empty shell, and React takes over in the browser. No SEO, slow initial loads, and you still need to build a REST/GraphQL API.
  • Jinja + Islands: Server-render with templates, then sprinkle React components for interactivity. But now you're thinking in two different worlds. And coordinating state across islands is not easy.

JavaScript developers use full stack frameworks like Next.js — full SSR, hydration, and seamless client/server data flow. Most python developers don't want to leave python ecosystem for the backend needs, and many want to use react for the frontend.

PyReact Start aims to solve this by providing a zero-config way to build full-stack React + Python applications. Your FastAPI routes render React components directly. Full SSR, full hydration, no API layer to build. It's a thin wrapper around Inertia.js and FastAPI. It assumes bun runtime so it can provide zero config experience.

  • 🚀 Zero Config: Just install and run. Handles TS, TSX/JSX, CSS bundling along with Tailwind support out of the box.
  • 🐍 Python-First: FastAPI backend with Python's full ecosystem.
  • ⚛️ Modern React: React 19 with server-side rendering out of the box.
  • Bun-Powered: Lightning-fast bundling and SSR performance.

Requirements:

  • Bun v1.0+ must be installed
  • Your project needs a package.json with React and Inertia dependencies

Quick Start

1. Setup a new project

mkdir my-app && cd my-app

# Create pyproject.toml with Python dependencies
cat > pyproject.toml << 'EOF'
[project]
name = "my-app"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = [
    "pyreact-start",
    "fastapi",
    "uvicorn",
]
EOF

# Create package.json with JS dependencies
cat > package.json << 'EOF'
{
  "name": "my-app",
  "type": "module",
  "private": true,
  "dependencies": {
    "@inertiajs/react": "^2.2.18",
    "react": "^19.2.0",
    "react-dom": "^19.2.0"
  },
  "devDependencies": {
    "bun-plugin-tailwind": "^0.1.2",
    "tailwindcss": "^4.1.17"
  }
}
EOF

# Install dependencies
uv sync
bun install

# Create directories
mkdir -p backend frontend/pages static
touch backend/__init__.py

2. Create your FastAPI backend

# backend/main.py
from fastapi import FastAPI, Request
from fastapi.staticfiles import StaticFiles
from pyreact_start import Inertia

app = FastAPI()
inertia = Inertia(app)
app.mount("/static", StaticFiles(directory="static"), name="static")

@app.get("/")
async def home(request: Request):
    return await inertia.render("Home", {"message": "Hello!"}, request)

if __name__ == "__main__":
    import uvicorn
    uvicorn.run("backend.main:app", host="0.0.0.0", port=8000, reload=True)

3. Create your first page

// frontend/pages/Home.jsx
export default function Home({ message }) {
  return <h1>{message}</h1>;
}
/* frontend/styles.css */
@import "tailwindcss";

4. Run!

# Terminal 1: Frontend dev server
pyreact dev

# Terminal 2: FastAPI backend
APP_ENV=development python -m backend.main

Visit http://localhost:8000 🎉

Project Structure

my-app/
├── backend/
│   └── main.py           # FastAPI application
├── frontend/
│   ├── pages/            # React pages (auto-discovered)
│   ├── layouts/          # Shared layouts (optional)
│   ├── components/       # Reusable components (optional)
│   └── styles.css        # Tailwind entry point
├── static/dist/          # Generated assets (gitignored)
├── .pyreact/             # Generated entry files (gitignored)
├── package.json          # JS dependencies
└── pyproject.toml        # Python dependencies

The .pyreact/ directory contains auto-generated files:

  • pages.js — Page map (scanned from frontend/pages/)
  • client.jsx — Client-side entry point
  • ssr.jsx — Server-side rendering entry point

Commands

Command Description
pyreact dev Start dev server with hot reloading
pyreact build Build optimized production bundles
pyreact ssr Start the SSR server for production

Production

# Build optimized bundles
pyreact build

# Start the SSR server (background)
pyreact ssr &

# Start the FastAPI server
APP_ENV=production python -m backend.main

How It Works

  1. Auto-generated Entry Points: When you run pyreact dev or pyreact build, the CLI generates entry files in .pyreact/ that wire up your pages.
  2. Page Discovery: All .jsx files in frontend/pages/ are automatically discovered and mapped.
  3. Inertia.js Integration: Your FastAPI routes render React components directly, with automatic SSR.
  4. Tailwind CSS: Styles are processed via bun-plugin-tailwind during bundling.

Requirements

  • Python 3.11+
  • Bun v1.0+

Examples

See the examples/ directory:

  • basic-app — Minimal single-page example
  • tasks-app — Complex multi-page app with authentication with client side routing.

License

MIT

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

pyreact_start-0.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

pyreact_start-0.1.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file pyreact_start-0.1.0.tar.gz.

File metadata

  • Download URL: pyreact_start-0.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.29

File hashes

Hashes for pyreact_start-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a258502847b82b0e4665f3eb71911fd8e5efc7e893a501b5c51932c2c969eea2
MD5 175aa1b4f0cea2e02d7636c119e4c015
BLAKE2b-256 e0332472eb1b0a11009d017975f8eead617764941f6b722571190a252f5b5554

See more details on using hashes here.

File details

Details for the file pyreact_start-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyreact_start-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0699b4979d9a30463fb81fa636880b021415aa85bf37181a8aa666c295a3998
MD5 4db87abdd354b7ebcaa8054e7757db70
BLAKE2b-256 6ce3435351da856f1252b8e56116c6579f7f425a4b6d7a08137de6830e77a476

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