Reflex — Full-Stack Web Apps in Pure Python
Build reactive web apps without JavaScript. Frontend and backend in one Python codebase. Deploys anywhere. 28K+ GitHub stars.
Staging seguro para este activo
Este activo primero queda en staging. El prompt copiado pide inspeccionar los archivos staged antes de activar scripts, config MCP o config global.
npx -y tokrepo@latest install 2cbe9a3d-1cfc-4037-95d0-d90711bb9cbc --target codexPrimero deja archivos en staging; la activación requiere revisar el README y el plan staged.
What it is
Reflex is an open-source Python framework that lets you build full-stack web applications without writing any JavaScript. You define your UI with Python components, handle state with Python classes, and Reflex compiles everything to a React frontend with a FastAPI backend. The framework handles the full stack: routing, state management, database ORM, and deployment.
It targets Python developers who want to build interactive web apps without learning JavaScript, React, or managing separate frontend and backend codebases.
How it saves time or tokens
Reflex eliminates the context-switching between Python and JavaScript that slows down development. AI developers can build dashboards, admin panels, and user-facing apps for their ML models using the same language they use for data science and model training. The component-based architecture means you compose UIs from reusable Python functions, and hot reload shows changes instantly during development.
How to use
- Install and create a project:
pip install reflex
reflex init
reflex run
- Define a component:
import reflex as rx
def index():
return rx.box(
rx.heading('My AI App', size='lg'),
rx.text('Built with Reflex'),
rx.button('Click me', on_click=rx.window_alert('Hello'))
)
app = rx.App()
app.add_page(index)
- Add state management:
class State(rx.State):
count: int = 0
def increment(self):
self.count += 1
def counter():
return rx.box(
rx.text(f'Count: {State.count}'),
rx.button('Add', on_click=State.increment)
)
Example
import reflex as rx
import openai
class ChatState(rx.State):
messages: list[dict] = []
input_text: str = ''
async def send_message(self):
client = openai.OpenAI()
self.messages.append({'role': 'user', 'content': self.input_text})
response = client.chat.completions.create(
model='gpt-4o',
messages=self.messages
)
answer = response.choices[0].message.content
self.messages.append({'role': 'assistant', 'content': answer})
self.input_text = ''
def chat_page():
return rx.box(
rx.foreach(ChatState.messages, lambda m: rx.text(m['content'])),
rx.input(value=ChatState.input_text, on_change=ChatState.set_input_text),
rx.button('Send', on_click=ChatState.send_message)
)
Related on TokRepo
- AI tools for coding -- Developer tools with AI integration
- Featured workflows -- Discover curated developer tools
Common pitfalls
- Reflex compiles to React under the hood. Complex custom components may require understanding React concepts even though you write Python.
- Performance for highly interactive UIs may lag compared to native React because state updates round-trip through the Python backend.
- The ecosystem of third-party components is growing but smaller than React's. Check if the UI components you need are available before starting a large project.
Preguntas frecuentes
No. Reflex is designed so you write everything in Python. The framework compiles your Python component definitions to React and handles the frontend build process automatically. For advanced customization, you can wrap custom React components, but this is optional.
Yes. Reflex provides a built-in deploy command (reflex deploy) that handles hosting. You can also export the app as a static site or deploy the full-stack version to any server that runs Python. Docker deployment is supported for containerized environments.
Reflex includes a built-in ORM based on SQLAlchemy. You define models as Python classes and Reflex handles migrations and queries. It supports SQLite for development and PostgreSQL for production. You can also connect to external databases using any Python database library.
Yes. Reflex is popular among data scientists and ML engineers who want to build model dashboards, experiment tracking UIs, and internal tools. Since you write Python, you can directly import and use ML libraries (scikit-learn, PyTorch, pandas) in your app logic.
Streamlit is simpler for quick data apps and dashboards with a script-based approach. Reflex provides a full web framework with routing, component composition, and production deployment. Choose Streamlit for rapid prototypes and Reflex for production applications that need custom UIs and multi-page navigation.
Referencias (3)
- Reflex GitHub Repository— Reflex is an open-source Python framework for full-stack web apps
- Reflex Documentation— Reflex compiles Python to React frontend with FastAPI backend
- Reflex Blog— Python-based web frameworks reduce context switching for data scientists
Relacionados en TokRepo
Fuente y agradecimientos
Discusión
Activos relacionados
bolt.diy — AI Full-Stack App Builder, Any LLM
Community fork of Bolt.new. Prompt, edit, and deploy full-stack web apps with any LLM provider. 19K+ GitHub stars.
Dioxus — Full-Stack App Framework for Web, Desktop, and Mobile
Dioxus is a full-stack app framework for Rust with a React-like API. Build web (WASM), desktop (native WebView), mobile (iOS/Android), TUI, and server-rendered apps from one codebase. Hooks, components, server functions, and hot reloading.
Remix — Full-Stack Web Framework on Web Fundamentals
Remix is a full-stack React framework built on web fundamentals, focused on web standards, nested routing, progressive enhancement, and fast data loading. Now merged into React Router v7 but still widely used.
MCP-Use — Build Full-Stack MCP Apps
MCP-Use is a full-stack framework for building MCP apps that work with ChatGPT, Claude, and any AI agent. 9.6K+ stars. Python SDK. MIT.