Reflex DevTools
Real-time debugging and inspection for Reflex applications
What is Reflex DevTools?
Reflex DevTools is a powerful debugging toolkit for applications built with the @flexsurfer/reflex library. It provides real-time inspection of your application's state, events, and traces through an intuitive web-based dashboard.
Key Features
- 📊 Database State Inspection - Visualize your entire application state in real-time
- 🔄 Real-time Event Tracing - Watch events and state changes as they happen
- 🔥 Real-time Reactions and Render Tracing - Watch all reactions being created and run, and rendering processes
- ⏱ Performance Profiling - Analyze events and reactions times and bottlenecks in real-time
- 🤖 AI-Powered Debugging - MCP integration enables AI assistants like Claude or Cursor to inspect traces and dispatch events
- 🎨 Beautiful Dashboard - Clean, modern UI with dark/light theme support
- 📱 React & React Native Support - Works seamlessly with both platforms
- ⚡ Zero Configuration - Get started with just two lines of code
Quick Start
Installation
npm install --save-dev @flexsurfer/reflex-devtools
# or
yarn add -D @flexsurfer/reflex-devtools
# or
pnpm add -D @flexsurfer/reflex-devtools1. Enable in Your App
Add these lines to your app's entry point (e.g., main.tsx or App.tsx):
import { enableTracing } from '@flexsurfer/reflex';
import { enableDevtools } from '@flexsurfer/reflex-devtools';
// Enable tracing for Reflex events
enableTracing();
// Connect to devtools server
enableDevtools({
serverUrl: 'localhost:4000' // Optional: defaults to localhost:4000
});2. Start the DevTools Server
npx reflex-devtoolsOr with custom configuration:
npx reflex-devtools --port 3000 --host 0.0.0.03. Open the Dashboard
Navigate to http://localhost:4000 in your browser to see the DevTools dashboard.
Usage Examples
Basic Setup
// main.tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import { enableTracing } from '@flexsurfer/reflex';
import { enableDevtools } from '@flexsurfer/reflex-devtools';
import App from './App';
enableTracing();
enableDevtools();
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>
);Custom Configuration
enableDevtools({
serverUrl: 'localhost:3001',
enabled: process.env.NODE_ENV === 'development'
});AI-Powered Debugging with MCP
Reflex DevTools now supports the Model Context Protocol (MCP), enabling AI assistants like Claude and Cursor to directly inspect your application traces and dispatch events!
Quick Setup
Install the MCP server:
bashnpm install -g @flexsurfer/reflex-devtools-mcpStart DevTools server with MCP support:
bashnpx reflex-devtools --mcpImportant: The
--mcpflag enables trace storage. Without it, MCP will not work.Configure your AI client:
For Claude Desktop (
~/Library/Application Support/Claude/claude_desktop_config.json):json{ "mcpServers": { "reflex-devtools": { "command": "npx", "args": ["reflex-devtools-mcp"], "env": {} } } }For Cursor IDE (Cursor Settings →
settings.json):json{ "mcp.servers": { "reflex-devtools": { "command": "npx", "args": ["reflex-devtools-mcp"], "env": {} } } }Restart your AI client and ask questions like:
- "What's the current app state and what user actions led to this state?"
- "Navigate to the user profile page and select the first item in the list"
- "Find slow event handlers that take longer than 100ms to execute"
- "Show me active subscriptions that might be causing unnecessary re-renders"
Configuration Options
Client Configuration
interface DevtoolsConfig {
serverUrl?: string; // Default: 'localhost:4000'
enabled?: boolean; // Default: true
}Server Configuration
npx reflex-devtools [options]
Options:
-p, --port <port> Port number (default: 4000)
-h, --host <host> Host address (default: localhost)
--help Show help messageFeatures in Detail
Database State Inspection
The DevTools dashboard shows your entire application state in a hierarchical, searchable tree view. You can:
- Expand/collapse state branches
- Search for specific keys or values
- Watch changes in real-time as you interact with your app
- Copy state paths for use in subscriptions or events
Real-time Event Tracing
Every event dispatched in your Reflex app is captured and displayed in the Events panel:
- Event timeline with timestamps
- Event parameters and payloads
- State changes caused by each event
- Performance metrics for event execution time
Reactions and Render Tracing
Monitor how your app responds to state changes:
- Subscription creation and disposal
- Reaction execution with timing
- Component re-renders triggered by subscriptions
- Performance bottlenecks in reactive chains
Performance Profiling
Identify and optimize slow operations:
- Event execution times with detailed breakdowns
- Subscription computation times
- Render performance metrics
- Memory usage patterns