nook
Browse the docs

Components

Log viewer

Native

Windowed application logs with search, level filters, pause, wrapping and clipboard export.

See the prompt

Production ยท deploy a7c42e

ERRORRestored build cache from fra1
INFOCompiling server routes
INFOType check passed in 1.8s
INFORetrying upload: upstream connection reset
DEBUGAsset manifest written
INFOHealth check passed: /api/health
INFOBuild cache unavailable; using local compilation
WARNDeployment promoted to production
DEBUGRestored build cache from fra1
INFOCompiling server routes
INFOType check passed in 1.8s
INFORetrying upload: upstream connection reset
DEBUGAsset manifest written
INFOHealth check passed: /api/health
5,000 lines ยท Following tail

Installation

npx nook-ui@latest add log-viewer

Prompt

Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.

Short. For assistants that can run commands in your project.

Plain text
Add the Nook "Log viewer" component to this project, exactly as Nook ships it.

Windowed application logs with search, level filters, pause, wrapping and clipboard export.

Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add log-viewer`. It writes `components/ui/log-viewer.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/log-viewer.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:

```tsx
"use client";
import * as React from "react";
import { LogViewer, type LogEntry } from "@/components/ui/log-viewer";
const messages = [
  "Restored build cache from fra1",
  "Compiling server routes",
  "Type check passed in 1.8s",
  "Retrying upload: upstream connection reset",
  "Asset manifest written",
  "Health check passed: /api/health",
  "Build cache unavailable; using local compilation",
  "Deployment promoted to production",
];
const initial: LogEntry[] = Array.from({ length: 5000 }, (_, index) => ({
  id: String(index),
  time: `14:${String(Math.floor(index / 60) % 60).padStart(2, "0")}:${String(index % 60).padStart(2, "0")}`,
  level:
    index % 31 === 0
      ? "error"
      : index % 7 === 0
        ? "warn"
        : index % 4 === 0
          ? "debug"
          : "info",
  message: messages[index % messages.length]!,
}));
export default function LogDefault() {
  const [entries, setEntries] = React.useState(initial);
  React.useEffect(() => {
    if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
    let tick = 0;
    const timer = setInterval(() => {
      tick++;
      setEntries((current) => [
        ...current,
        {
          id: `live-${tick}`,
          time: `15:24:${String(tick % 60).padStart(2, "0")}`,
          level: tick % 8 === 0 ? "error" : "info",
          message:
            tick % 8 === 0
              ? "Health check retry: upstream timeout"
              : "Health check passed: /api/health",
        },
      ]);
    }, 2500);
    return () => clearInterval(timer);
  }, []);
  return (
    <LogViewer
      className="max-w-2xl"
      title="Production ยท deploy a7c42e"
      entries={entries}
    />
  );
}
```

API
- `LogViewer`: Renders only the visible window plus overscan; wrapped rows are measured.
  - `entries` (`LogEntry[]`): Append entries with stable unique id, time, level and message. Replace the array to update.
  - `height` (`number`): Viewport height in pixels, default 288.
  - `title` (`string`): Heading and accessible log name.

Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Keyboard users can scroll the named log and operate every filter. Log rows do not announce continuously; only counts of new errors are announced politely. Levels use words and marks.

Done when the component renders like the example in light and dark mode and the project type-checks.

Usage

"use client";
import * as React from "react";
import { LogViewer, type LogEntry } from "@/components/ui/log-viewer";
const messages = [
  "Restored build cache from fra1",
  "Compiling server routes",
  "Type check passed in 1.8s",
  "Retrying upload: upstream connection reset",
  "Asset manifest written",
  "Health check passed: /api/health",
  "Build cache unavailable; using local compilation",
  "Deployment promoted to production",
];
const initial: LogEntry[] = Array.from({ length: 5000 }, (_, index) => ({
  id: String(index),
  time: `14:${String(Math.floor(index / 60) % 60).padStart(2, "0")}:${String(index % 60).padStart(2, "0")}`,
  level:
    index % 31 === 0
      ? "error"
      : index % 7 === 0
        ? "warn"
        : index % 4 === 0
          ? "debug"
          : "info",
  message: messages[index % messages.length]!,
}));
export default function LogDefault() {
  const [entries, setEntries] = React.useState(initial);
  React.useEffect(() => {
    if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
    let tick = 0;
    const timer = setInterval(() => {
      tick++;
      setEntries((current) => [
        ...current,
        {
          id: `live-${tick}`,
          time: `15:24:${String(tick % 60).padStart(2, "0")}`,
          level: tick % 8 === 0 ? "error" : "info",
          message:
            tick % 8 === 0
              ? "Health check retry: upstream timeout"
              : "Health check passed: /api/health",
        },
      ]);
    }, 2500);
    return () => clearInterval(timer);
  }, []);
  return (
    <LogViewer
      className="max-w-2xl"
      title="Production ยท deploy a7c42e"
      entries={entries}
    />
  );
}

Examples

Errors and warnings

Payments worker

INFOPicked up job charge_8841
WARNCard processor answered slowly (2.4s)
ERRORCharge declined: insufficient funds for cus_Mj3k
INFOSent the payment failed email
ERRORRetry 1 of 3 failed: processor timeout
5 lines ยท Following tail

Short log

Nightly backup

DEBUGSnapshot started
INFOUploaded 3.2 GB to the backup bucket
INFOBackup finished
3 lines ยท Following tail

Empty log

Deploy log

No logs match. Change your search or levels.

0 lines ยท Following tail

Long messages

Worker log

INFOPicked up job export-8841 for workspace acme-corp with 12 filters applied
WARNQuery took 8.4 s, which is above the 5 s budget: SELECT orders.id, orders.total, customers.email FROM orders JOIN customers ON customers.id = orders.customer_id WHERE orders.created_at >= '2026-01-01'
ERRORUpload to s3://acme-exports/2026/11/export-8841.csv failed: connection reset by peer after 3 retries. The file stays on disk for 24 hours.
3 lines ยท Following tail

Compact tail

Last deploy

INFOBuild started
INFOTests passed (212)
INFODeployed to production
3 lines ยท Following tail

Props

LogViewer

Renders only the visible window plus overscan; wrapped rows are measured.

PropTypeDefaultDescription
entriesLogEntry[]โ€“Append entries with stable unique id, time, level and message. Replace the array to update.
heightnumberโ€“Viewport height in pixels, default 288.
titlestringโ€“Heading and accessible log name.

Accessibility

Keyboard users can scroll the named log and operate every filter. Log rows do not announce continuously; only counts of new errors are announced politely. Levels use words and marks.

Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.