
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@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: '/__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.
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.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

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.