Reatom provides comprehensive developer tools for debugging and inspecting your application state, actions, and dependencies. This guide covers the built-in logger and the DevTools UI.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/reatom/reatom/llms.txt
Use this file to discover all available pages before exploring further.
Quick Start
Install DevTools
Basic Logger Setup
The simplest way to debug Reatom apps is using the built-inconnectLogger:
Using the Logger
Basic Logging
Filtering Logs
Filter which atoms and actions appear in logs:Excluding Private State
By convention, atoms starting with_ are private:
The default filter pattern in DevTools excludes names starting with
_ or ._ to hide internal implementation details.Log Levels and Formatting
State Change Logging
Log only when specific state changes:DevTools UI
The@reatom/devtools package provides a visual interface for inspecting your Reatom state graph.
Installation and Setup
DevTools Configuration
DevTools API
The DevTools instance provides programmatic control:DevTools Features
Logs View
The main logs panel shows:- Action calls with parameters
- State changes with before/after values
- Dependency chains showing what triggered what
- Timestamps for performance analysis
- Stack traces for debugging
Filter Actions
Create custom filters to focus on specific parts of your state:- Filter mode: Show only matching logs
- Hide mode: Hide matching logs
- Exclude mode: Remove from collection entirely (performance optimization)
- Highlight mode: Color-code matching logs
Log Controls
- Clear logs: Remove all collected logs
- Clear lines: Remove cause chain highlight lines
- Recording: Pause/resume log collection
- Preview: Toggle inline payload preview
- Time: Toggle timestamp display
- Snap: Create snapshot of current visible logs
- Size: Adjust log collection limit
States View
Hierarchical tree view of all atoms in your application:- Organized by name separator (e.g.,
user.profile.name) - Excludes actions and private atoms by default
- Real-time updates via
proto.updateHooks - “Reload” button to force snapshot refresh
- “Log” button to output state to console
The states view uses
structuredClone when possible, falling back to live data references for non-cloneable objects.Inspector
Click any state value to open the inspector panel:Inspector Actions
- Edit: Open JSON form to modify state (uses
JSON.parse) - History: View diff between current and previous states (max 10 entries)
- Log to console: Output current value to browser console
- Copy JSON: Copy stringified value to clipboard
- Download: Save value as JSON file
- Convert to plain JSON: Remove Reatom atoms from data structure
Cause Chain Tracing
Click any log entry to highlight its cause chain:- Visual lines connect causes to effects
- Shows dependencies that triggered updates
- Helps understand why state changed
- Traces through async boundaries
Time Travel Debugging
Use snapshots to capture and restore state:Integration with Browser DevTools
Chrome/Edge DevTools Extension
Reatom integrates with browser DevTools through the@reatom/devtools package:
- The DevTools UI renders in a Shadow DOM container with isolated styles
- Uses ObservableHQ Inspector for rich data visualization
- Includes jsondiffpatch for visual state diffs
Console Integration
Persistence
DevTools settings are saved to localStorage:- Filter configurations (with version key)
- View preferences (logs vs. states)
- Panel visibility
- Size settings
Settings use Zod for validation to handle version migrations safely.
Performance Considerations
Production Builds
Always guard DevTools and logging with environment checks:Log Collection Limits
Use theinitSize option to prevent memory issues:
Exclude Filters
Use “exclude” mode filters for high-frequency atoms:Debugging Recipes
Find Why State Changed
Click the log entry
This highlights the cause chain showing all dependencies that triggered the update.
Debug Async Operations
Enable stack traces to see async call chains:Inspect Complex State
Use the inspector’s “Convert to plain JSON” feature to remove Reatom wrappers:- Click the state value in DevTools
- Click “Convert to plain JSON”
- Copy or download the plain object
Track State Over Time
Use history diffs to see how state evolved:- Click a state value in the inspector
- Click “History” button
- Review visual diffs showing changes over time
Best Practices
- Name everything - Give all atoms and actions descriptive names for better logs
- Use namespacing - Structure names like
user.profile.emailfor hierarchical views - Filter aggressively - Hide internal implementation details with filters
- Check logs regularly - Catch unexpected updates early in development
- Use LOG liberally - Add logging to complex operations while developing
- Guard production - Always wrap DevTools in environment checks
Troubleshooting
DevTools Not Appearing
Check that:- DevTools is created before atoms are accessed
initVisibilityistrue- You’re in development mode
- No console errors from DevTools initialization
Missing Logs
Ensure:connectLogger()is called before atom updates- Your filters aren’t hiding the logs
- Recording is enabled (check the “recording” toggle)
Performance Issues
If DevTools slows your app:- Reduce
initSizelimit - Add exclude filters for high-frequency atoms
- Disable recording when not actively debugging
- Close the DevTools panel (it still collects but renders less)
Further Reading
- Performance Guide - Optimize your Reatom app
- Logger API Reference - Complete logger options
- DevTools Source - Implementation details