A sleek, lightweight React component that captures and displays console output with an elegant hover-to-expand UI. Perfect for debugging, error reporting, and streamlined development workflows. Designed to be added to page headers for quick developer access to crucial console information.
- π― Smart Console Interception: Automatically captures all console output (log, error, warn, info, debug)
- π Intelligent Filtering: Built-in suppression for common third-party library warnings
- π One-Click Copy: Copy console output to clipboard with rich context information
- π¨ Elegant UI: Minimalist floating button that expands on hover
- π·οΈ Visual Indicators: Badge showing error/warning counts with color coding
- β‘ Zero Configuration: Works out of the box with sensible defaults
- π§ Highly Customizable: Position, theme, size, and suppression patterns
- π¦ Lightweight: Minimal bundle size impact
- π Framework Agnostic Core: Console capture works anywhere, React UI optional
- π Header Integration: Perfect for adding to page headers for persistent developer access
npm install fetch-dev-console
Install the required Material-UI dependencies:
npm install @mui/material @emotion/react @emotion/styled @mui/icons-material
import React from 'react';
import { FetchDevConsole, initConsoleCapture } from 'fetch-dev-console';
// Initialize console capture (call once in your app)
initConsoleCapture();
function App() {
return (
<div>
<header>
<h1>My App</h1>
{/* Add to header for persistent developer access */}
{process.env.NODE_ENV === 'development' && <FetchDevConsole />}
</header>
{/* Your app content */}
</div>
);
}
export default App;
Perfect for integrating into existing React projects while maintaining the ability to receive updates:
# β οΈ Important: Ensure your working tree is clean before adding subtree
git status # Check for uncommitted changes
git add . # Stage any changes
git commit -m "Save current work before adding fetch-dev-console"
# Add fetch-dev-console as a subtree
git subtree add --prefix=src/components/fetch-dev-console https://github.com/mariov96/fetch-dev-console.git main --squash
Usage after subtree integration:
// Import from your local subtree
import { FetchDevConsole, initConsoleCapture } from './components/fetch-dev-console/src';
// Initialize in your main App component
function App() {
useEffect(() => {
initConsoleCapture();
}, []);
return (
<div>
<header className="app-header">
<nav>Your Navigation</nav>
{/* Add to header for quick developer access */}
{process.env.NODE_ENV === 'development' && (
<FetchDevConsole position="top-right" />
)}
</header>
{/* Your app content */}
</div>
);
}
Future Updates:
# Pull updates from the fetch-dev-console repo
git subtree pull --prefix=src/components/fetch-dev-console https://github.com/mariov96/fetch-dev-console.git main --squash
If you prefer not to use git subtree:
# Clone to temporary location
git clone https://github.com/mariov96/fetch-dev-console.git temp-console
mkdir -p src/components/fetch-dev-console
cp -r temp-console/* src/components/fetch-dev-console/
rm -rf temp-console
# Install Material-UI dependencies if not already installed
npm install @mui/material @emotion/react @emotion/styled @mui/icons-material
# Add to your project
git add src/components/fetch-dev-console/
git commit -m "Add fetch-dev-console component"
// Layout component with header integration
function Layout({ children }) {
return (
<div className="app-layout">
<header className="main-header">
<div className="header-content">
<Logo />
<Navigation />
{/* Developer console access in header */}
{process.env.NODE_ENV === 'development' && (
<div className="dev-tools">
<FetchDevConsole
position="top-right"
theme="auto"
size="medium"
/>
</div>
)}
</div>
</header>
<main>{children}</main>
</div>
);
}
- "fatal: working tree has modifications": Commit or stash your changes before running
git subtree add
- Component not found: Check the import path matches your actual file structure
- Styles not loading: Ensure CSS imports are included in your build process
- Material-UI errors: Make sure all required MUI dependencies are installed:
@mui/material
,@emotion/react
,@emotion/styled
,@mui/icons-material
- Console not capturing: Make sure
initConsoleCapture()
is called before any console output
Hover to expand, click to copy, dropdown for filtering options
Initialize the console capture system. Call this once in your application root.
Options:
suppressPatterns?: string[]
- Array of patterns to suppress from consolemaxLogs?: number
- Maximum logs to keep in memory (default: 1000)
initConsoleCapture({
suppressPatterns: [
'react-beautiful-dnd',
'Support for defaultProps will be removed',
'Your custom warning pattern'
],
maxLogs: 500
});
Props:
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'
- Button positiontheme?: 'light' | 'dark' | 'auto'
- Color themesize?: 'small' | 'medium' | 'large'
- Button size
<FetchDevConsole
position="top-right"
theme="dark"
size="large"
/>
Generate test console messages for testing the capture system.
import { testConsoleCapture } from 'fetch-dev-console';
const handleTest = () => {
testConsoleCapture();
};
- π Bug Reports: Easily copy console output to include in bug reports
- π¨βπ» Development: Quick access to console messages without opening DevTools
- π Education: Teaching and demonstrating console behavior
- π§ Support: Help users provide console output for troubleshooting
- π Monitoring: Track console activity during development
- ποΈ Header Integration: Persistent developer access across all pages
// Top-left dark theme, large size for header placement
<FetchDevConsole
position="top-left"
theme="dark"
size="large"
/>
// Use console capture without React
import { initConsoleCapture } from 'fetch-dev-console';
initConsoleCapture({
suppressPatterns: ['unwanted-warning'],
maxLogs: 200
});
// Access captured logs
console.log(window.consoleCapture.logs);
// Copy programmatically
await window.copyAllConsole(true); // errors only
The component is designed to be included only in development builds:
// Automatic exclusion from production
{process.env.NODE_ENV === 'development' && <FetchDevConsole />}
// Or with custom environment logic
{(isDevelopment || isStaging) && <FetchDevConsole />}
This ensures it's automatically excluded from production bundles while providing crucial debugging access during development.
# Clone the repository
git clone https://github.com/mariov96/fetch-dev-console.git
cd fetch-dev-console
# Install dependencies
npm install
# Start development mode
npm run dev
# Build for production
npm run build
MIT Β© Mario Vaccari
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
Give a βοΈ if this project helped you!
Made with β€οΈ by Mario Vaccari