---
title: "Next.js App Router"
description: "Wrap route handlers with withLogger() and mount clientLogHandler on the configured ingestion path."
canonical_url: "https://www.blyp.dev/docs/integrations/nextjs"
markdown_url: "https://www.blyp.dev/docs/integrations/nextjs.md"
last_updated: "2018-10-20"
x_farming_labs_generated_preamble: true
---

# Next.js App Router
URL: /docs/integrations/nextjs
LLM index: /llms.txt
Description: Wrap route handlers with withLogger() and mount clientLogHandler on the configured ingestion path.

# Next.js App Router

Import from `@blyp/core/nextjs`.

```ts
import { createLogger } from "@blyp/core/nextjs";

const nextLogger = createLogger({
  level: "info",
});

export const GET = nextLogger.withLogger(async (_request, _context, { log }) => {
  log.info("next-route");
  return Response.json({ ok: true });
});
```

## Client ingestion route

Mount `clientLogHandler` on the same path configured for client logging.

```ts
// app/inngest/route.ts
import { createLogger } from "@blyp/core/nextjs";

const nextLogger = createLogger();

export const POST = nextLogger.clientLogHandler;
```

If you mount the handler on a path that does not match the configured ingestion path, Blyp returns a `500` mismatch response.

## What auto-logged requests look like

With automatic request logging enabled, Blyp emits terminal output like:

```text
[INFO]  GET  /health        200  2ms
[INFO]  POST /checkout      200  143ms
[INFO]  GET  /users/42      404  8ms
[ERROR] POST /payments      500  1203ms
```

Fields included automatically: method, path, status code, and duration.

**In production (NDJSON):**

```json
{"level":"info","time":1710000000000,"msg":"GET /health","type":"http_request","method":"GET","url":"/health","statusCode":200,"responseTime":2}
{"level":"info","time":1710000000001,"msg":"POST /checkout","type":"http_request","method":"POST","url":"/checkout","statusCode":200,"responseTime":143}
```

## Relevant types

```ts
import type {
  NextJsLoggerConfig,
  NextJsLoggerFactory,
  NextJsHandlerWithLogger,
  NextJsRouteContext,
} from "@blyp/core/nextjs";
```

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
Docs-scoped sitemap: [/docs/sitemap.md](/docs/sitemap.md).
Well-known sitemap: [/.well-known/sitemap.md](/.well-known/sitemap.md).
