wilco - Server-Defined React Components ======================================= .. warning:: **Experimental Software** wilco is experimental software in active development. Breaking changes may occur until version 1.0. Use with care in production environments. **wilco** is a framework that enables Python backends to serve isolated React/TypeScript components. Components are defined in the Python codebase alongside their TypeScript implementations, then dynamically bundled with esbuild and loaded by the frontend at runtime. .. toctree:: :maxdepth: 1 :caption: Tutorials tutorials/index .. toctree:: :maxdepth: 1 :caption: How-To Guides how-to/fastapi how-to/django how-to/flask how-to/starlette .. toctree:: :maxdepth: 1 :caption: Specifications specs/index .. toctree:: :maxdepth: 1 :caption: Reference reference/cli reference/components reference/javascript .. toctree:: :maxdepth: 1 :caption: Explanation explanation/architecture explanation/bundling explanation/standalone-loader explanation/request-lifecycle explanation/live-preview Features -------- - **Co-located components** — Keep UI components next to the Python code that powers them - **No frontend build pipeline** — Components bundled on-the-fly with esbuild when requested - **Production-ready** — Pre-compile bundles with ``wilco build`` for static file serving - **Full source map support** — Debug TypeScript directly in browser devtools - **Component composition** — Components can dynamically load other components via ``useComponent`` - **Framework agnostic** — Works with FastAPI, Django, Flask, Starlette, or any ASGI/WSGI-compatible framework - **CLI tooling** — ``wilco serve`` for development, ``wilco build`` for production Quick example ------------- Create a component directory with Python and TypeScript files: .. code-block:: text my_components/ └── greeting/ ├── __init__.py ├── index.tsx └── schema.json Write your React component: .. code-block:: tsx // index.tsx interface GreetingProps { name: string; formal?: boolean; } export default function Greeting({ name, formal = false }: GreetingProps) { const message = formal ? `Good day, ${name}.` : `Hey ${name}!`; return
{message}
; } Mount the API in your Python application: .. code-block:: python # FastAPI example from pathlib import Path from fastapi import FastAPI from wilco import ComponentRegistry from wilco.bridges.fastapi import create_router app = FastAPI() registry = ComponentRegistry(Path("./my_components")) app.include_router(create_router(registry), prefix="/api") Load components in the frontend: .. code-block:: tsx import { useComponent } from '@wilcojs/react'; function App() { const Greeting = useComponent('greeting'); return