
Company News
Jerod Santo Joins Socket as Head of Media
Allow myself to introduce... myself.
@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.
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: '/__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
}
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 }}
/>
)}
</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';
/__client-logs but works better as /api/client-logs 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';
<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/__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.
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.

Company News
Allow myself to introduce... myself.

Research
/Security News
A Twitch browser extension on Chrome and Firefox forwards users’ live OAuth session tokens through proxies controlled by a Russian bot service.

Security News
Anthropic found biased reasoning and recklessness drove Claude Mythos 5 to publish malware on PyPI and compromise a security vendor.