Skip to content
Learn Netverks

Lesson

Step 21/36 58% through track

error-ui

Error UI

Last reviewed Jun 1, 2026 Content v20260601
Track mode
client_nextjs
Means
In-browser Next.js (client components)
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches Error UI: the concepts, APIs, and habits you need before advancing in Next.js.

Without Error UI, you will struggle to read or extend Next.js codebases and playground exercises.

You will apply Error UI in contexts like: Marketing sites, dashboards, e-commerce, and Vercel-style deployments that need hybrid static + dynamic pages.

Write TSX for Client Components, click Run—React 18 CDN + in-browser TSX compile; use client/server lessons explain App Router concepts; mountApp renders interactive UI; printOutput feeds the terminal.

When you can explain the previous lesson's ideas without copying starter code.

error.tsx defines a route-level error boundary for unexpected failures in Server or Client Components within that segment. It must be a Client Component because error boundaries require React client features.

Basic error boundary file

// app/dashboard/error.tsx
'use client';

export default function Error({
  error,
  reset,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  return (
    <div>
      <h2>Something went wrong</h2>
      <button onClick={() => reset()}>Try again</button>
    </div>
  );
}

not-found.tsx

For expected missing resources, call notFound() from next/navigation in a Server Component—it renders the nearest not-found.tsx, not the error boundary.

Errors vs empty states

  • notFound() — user requested a slug that does not exist
  • error.tsx — thrown exception, failed fetch, bug
  • try/catch in Server Component — return graceful inline UI for known failure modes

Self-check

  1. Why must error.tsx be a Client Component?
  2. When do you call notFound() instead of throwing?

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • error.tsx vs global?
  • Reset behavior?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump