- **edgeLimit**: (optional) Max number of properties or elements to include per object or array. Default: 100
```ts filename="next.config.ts" switcher
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
experimental: {
browserDebugInfoInTerminal: {
depthLimit: 5,
edgeLimit: 100,
},
},
}
export default nextConfig
```
```js filename="next.config.js" switcher
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
browserDebugInfoInTerminal: {
depthLimit: 5,
edgeLimit: 100,
},
},
}
module.exports = nextConfig
```
### Source location
Source locations are included by default when this feature is enabled.
```tsx filename="app/page.tsx" highlight={8}
'use client'
export default function Home() {
return (
<button
type="button"
onClick={() => {
console.log('Hello World')
}}
>
Click me
</button>
)
}
```
Clicking the button prints this message to the terminal.
```bash filename="Terminal"
[browser] Hello World (app/page.tsx:8:17)
```
To suppress them, set `showSourceLocation: false`.
- **showSourceLocation**: Include source location info when available.
```ts filename="next.config.ts" switcher
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
experimental: {
browserDebugInfoInTerminal: {
showSourceLocation: false,
},
},
},
}
}
export default nextConfig
```
```
```js filename="next.config.js" switcher
The new `logging.browserToTerminal` option supports the log level values (`true`, `'warn'`, `'error'`). Note that the object configuration options (`depthLimit`, `edgeLimit`, `showSourceLocation`) are no longer available in the new configuration.
description: Configure how data fetches are logged to the console when running Next.js in development mode.
description: Configure logging behavior in the terminal when running Next.js in development mode.
---
---
{/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
{/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
...
@@ -11,8 +11,6 @@ description: Configure how data fetches are logged to the console when running N
...
@@ -11,8 +11,6 @@ description: Configure how data fetches are logged to the console when running N
You can configure the logging level and whether the full URL is logged to the console when running Next.js in development mode.
You can configure the logging level and whether the full URL is logged to the console when running Next.js in development mode.
Currently, `logging` only applies to data fetching using the `fetch` API. It does not yet apply to other logs inside of Next.js.
```js filename="next.config.js"
```js filename="next.config.js"
module.exports = {
module.exports = {
logging: {
logging: {
...
@@ -60,6 +58,64 @@ module.exports = {
...
@@ -60,6 +58,64 @@ module.exports = {
}
}
```
```
### Browser Console Logs
You can forward browser console logs (such as `console.log`, `console.warn`, `console.error`) to the terminal during development. This is useful for debugging client-side code without needing to check the browser's developer tools.
```js filename="next.config.js"
module.exports = {
logging: {
browserToTerminal: true,
},
}
```
#### Options
The `browserToTerminal` option accepts the following values: