
Security News
Ruby's Bundler 4.0.18 Extends Cooldown to bundle lock and bundle cache
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.
@browser-echo/next
Advanced tools
Next.js App Router integration for streaming browser console logs to your dev terminal.
Next.js App Router integration for streaming browser console logs to your dev terminal.
Since Turbopack doesn't use Vite, this package provides a tiny route handler and an early script component to patch console.* methods and forward logs to your development server.
npm install -D @browser-echo/next
# or
pnpm add -D @browser-echo/next
Run the setup command to automatically create the route file:
npx @browser-echo/next setup
# or
pnpm dlx @browser-echo/next setup
This creates app/api/client-logs/route.ts with the necessary exports.
Configure the <BrowserEchoScript /> component with these options:
type BrowserLogLevel = 'log' | 'info' | 'warn' | 'error' | 'debug';
interface BrowserEchoScriptProps {
enabled?: boolean; // default: true (dev only)
route?: `/${string}`; // default: '/api/client-logs'
include?: BrowserLogLevel[]; // default: ['log','info','warn','error','debug']
preserveConsole?: boolean; // default: true (also keep logging in the browser)
tag?: string; // default: '[browser]'
// stacks
stackMode?: 'none' | 'condensed' | 'full'; // default: 'condensed'
showSource?: boolean; // default: true (when available)
// batching
batch?: { size?: number; interval?: number }; // default: 20 / 300ms
// Opt-in network capture (fetch/XHR/WS)
networkLogs?: {
enabled?: boolean;
captureFull?: boolean;
bodies?: {
request?: boolean;
response?: boolean;
maxBytes?: number; // default 2048 bytes
allowContentTypes?: string[]; // default ['application/json','text/','application/x-www-form-urlencoded']
prettyJson?: boolean; // default true
};
};
}
enabled: Toggle the entire functionality (automatically disabled in production)route: The endpoint path where logs are sent (must match your route file location)include: Which console methods to capture and forwardpreserveConsole: Whether to keep original console behavior in the browsertag: Prefix for terminal output to identify browser logsstackMode: How much stack trace information to include
'none': No stack traces'condensed' (default): Essential stack info only'full': Complete stack tracesshowSource: Include source file location hints (file:line:col)batch: Control log batching behavior
size: Max logs per batch (default: 20)interval: Max time between batches in ms (default: 300)Here's how to use <BrowserEchoScript /> with custom options:
// app/layout.tsx
import type { ReactNode } from 'react';
import BrowserEchoScript from '@browser-echo/next/BrowserEchoScript';
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en">
<head>
{process.env.NODE_ENV === 'development' && (
<BrowserEchoScript
route="/api/client-logs"
include={['warn', 'error']}
preserveConsole={true}
tag="[NextJS Browser]"
stackMode="condensed"
showSource={true}
batch={{ size: 10, interval: 500 }}
networkLogs={{
enabled: true,
bodies: { request: true, response: true, maxBytes: 2048 }
}}
/>
)}
</head>
<body>{children}</body>
</html>
);
}
This configuration:
/api/client-logs endpoint[NextJS Browser]Render the script in your root layout head (dev-only):
// app/layout.tsx
import type { ReactNode } from 'react';
import BrowserEchoScript from '@browser-echo/next/BrowserEchoScript';
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en">
<head>
{process.env.NODE_ENV === 'development' && <BrowserEchoScript />}
</head>
<body>{children}</body>
</html>
);
}
Forward logs to your terminal via a dedicated route:
// app/api/client-logs/route.ts
export { POST, runtime, dynamic } from '@browser-echo/next/route';
/api/client-logs (works best in Next.js 15+)runtime = 'nodejs' and dynamic = 'force-dynamic' to ensure it runs on Node and isn't cachedComplete setup example:
// app/layout.tsx
import type { ReactNode } from 'react';
import BrowserEchoScript from '@browser-echo/next/BrowserEchoScript';
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en">
<head>
{process.env.NODE_ENV === 'development' && (
<BrowserEchoScript
route="/api/client-logs"
include={['warn', 'error']}
stackMode="condensed"
/>
)}
</head>
<body>{children}</body>
</html>
);
}
// app/api/client-logs/route.ts
export { POST, runtime, dynamic } from '@browser-echo/next/route';
Next.js automatically discovers and forwards logs to MCP servers. No configuration needed in most cases!
📖 First, set up the MCP server for your AI assistant, then configure framework options below.
The Next.js route handler automatically detects MCP servers and forwards logs when available. When MCP is detected, terminal output is suppressed by default.
Discovery order:
BROWSER_ECHO_MCP_URL (normalized, trailing /mcp is stripped)http://127.0.0.1:5179 then http://localhost:5179.browser-echo-mcp.json (walks up parent directories)BROWSER_ECHO_MCP_URL=http://127.0.0.1:5179/mcp — Set MCP server URL (base URL is derived automatically). When set, the route will forward; terminal printing is suppressed unless explicitly disabled.BROWSER_ECHO_SUPPRESS_TERMINAL=1 — Force suppress terminal outputBROWSER_ECHO_SUPPRESS_TERMINAL=0 — Force show terminal output even when MCP is active// app/api/client-logs/route.ts
import { POST as BasePost } from '@browser-echo/next/route';
// Custom handler without MCP discovery
export async function POST(request: NextRequest) {
// Set environment to disable MCP
const originalMcpUrl = process.env.BROWSER_ECHO_MCP_URL;
delete process.env.BROWSER_ECHO_MCP_URL;
const result = await BasePost(request);
// Restore original env
if (originalMcpUrl) process.env.BROWSER_ECHO_MCP_URL = originalMcpUrl;
return result;
}
export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';
<BrowserEchoScript /> injects client-side code that patches console methodsIf you change the route path, update both places:
// Use custom route in script
<BrowserEchoScript route="/api/my-logs" />
// Create matching route file: app/api/my-logs/route.ts
export { POST, runtime, dynamic } from '@browser-echo/next/route';
This package depends on @browser-echo/core for the client-side functionality.
POST handler and write to disk as neededapp/api/client-logs/route.ts is exported and <BrowserEchoScript /> is rendered in <head>route propinclude: ['warn','error'] and use stackMode: 'condensed'MIT
FAQs
Next.js App Router integration for streaming browser console logs to your dev terminal.
The npm package @browser-echo/next receives a total of 81 weekly downloads. As such, @browser-echo/next popularity was classified as not popular.
We found that @browser-echo/next demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.

Company News
Socket is now in the AWS Security Hub Extended plan. Adopt it through AWS, apply committed spend, and block malicious open source packages.