Skip to content

flexsurfer/reflex-devtools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Reflex DevTools Logo

πŸ› οΈ Reflex DevTools

Real-time debugging and inspection for Reflex applications

License: MIT NPM Version PRs Welcome

Reflex DevTools Screenshot

✨ 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-devtools

1. 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-devtools

Or with custom configuration:

npx reflex-devtools --port 3000 --host 0.0.0.0

3. 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

  1. Install the MCP server:

    npm install -g @flexsurfer/reflex-devtools-mcp
  2. Start DevTools server with MCP support:

    npx reflex-devtools --mcp

    Important: The --mcp flag enables trace storage. Without it, MCP will not work.

  3. Configure your AI client:

    For Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):

    {
      "mcpServers": {
        "reflex-devtools": {
          "command": "npx",
          "args": ["reflex-devtools-mcp"],
          "env": {}
        }
      }
    }

    For Cursor IDE (Cursor Settings β†’ settings.json):

    {
      "mcp.servers": {
        "reflex-devtools": {
          "command": "npx",
          "args": ["reflex-devtools-mcp"],
          "env": {}
        }
      }
    }
  4. 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"

πŸ“š Full MCP Documentation β†’


πŸ”§ 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 message

πŸ—οΈ Architecture

Reflex DevTools consists of three main components:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    WebSocket/HTTP    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Your App      β”‚ ◀──────────────────▢ β”‚  DevTools       β”‚
β”‚                 β”‚                      β”‚  Server         β”‚
β”‚ - Reflex SDK    β”‚                      β”‚                 β”‚
β”‚ - DevTools SDK  β”‚                      β”‚ - Express API   β”‚
β”‚                 β”‚                      β”‚ - WebSocket     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                   β”‚
                                                   β”‚ HTTP
                                                   β–Ό
                                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                         β”‚   Web Dashboard β”‚
                                         β”‚                 β”‚
                                         β”‚ - React UI      β”‚
                                         β”‚ - Real-time     β”‚
                                         β”‚   Updates       β”‚
                                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Components:

  1. Client SDK (/client) - Lightweight SDK that integrates with your app
  2. DevTools Server (/server) - Express server with WebSocket support
  3. Web Dashboard (/ui) - React-based debugging interface

πŸ› οΈ Development & Contributing

We welcome contributions! Here's how to get started:

Prerequisites

  • Node.js 18+
  • pnpm (recommended) or npm/yarn

Setup Development Environment

# Clone the repository
git clone https://github.com/flexsurfer/reflex-devtools.git
cd reflex-devtools

# Install dependencies
pnpm install

# Start development servers
pnpm dev

This will start:

  • DevTools server on localhost:4000
  • UI development server with hot reload on localhost:5173
  • Test app on localhost:3000

Project Structure

packages/
β”œβ”€β”€ reflex-devtools/        # Main package (client SDK + server)
β”‚   β”œβ”€β”€ src/client/         # Client SDK for apps
β”‚   β”œβ”€β”€ src/server/         # DevTools server
β”‚   └── src/cli.ts          # CLI entry point
β”œβ”€β”€ reflex-devtools-mcp/    # MCP server for AI assistants
β”‚   β”œβ”€β”€ src/tools/          # MCP tool implementations
β”‚   └── src/cli.ts          # MCP CLI entry point
β”œβ”€β”€ reflex-devtool-ui/      # Web dashboard
β”‚   └── src/                # React components
└── reflex-test-app/        # Example app for testing

Development Commands

# Build all packages
pnpm build

# Build specific packages
pnpm build:devtools    # Build main devtools package
pnpm build:ui          # Build UI dashboard
pnpm build:mcp         # Build MCP server

# Run tests
pnpm test

# Start development servers
pnpm dev:ui            # Start UI in development mode
pnpm dev:server        # Start DevTools server (use --mcp for MCP support)
pnpm dev:testapp       # Start test app
pnpm dev:mcp           # Start MCP server in dev mode
pnpm start:mcp         # Start MCP server (production)

# Clean all builds
pnpm clean

Making Changes

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Test with the test app: pnpm dev:testapp
  5. Commit using conventional commits: git commit -m 'feat: add amazing feature'
  6. Push and create a Pull Request

Code Style

  • TypeScript for all code
  • ESLint + Prettier for formatting
  • Conventional Commits for commit messages
  • Component-based architecture for UI

πŸ“„ License

MIT License - see LICENSE file for details.


πŸ™ Acknowledgments

Built with ❀️ for the Reflex community. Special thanks to all contributors and the open-source projects that make this possible.


Happy Debugging! πŸ›βž‘οΈβœ¨

Made by @flexsurfer

About

Developer tools for applications built with the reflex library

Resources

License

Stars

Watchers

Forks