Coding task · Next.js course · Module 2: Routing and Layouts

Practice: Error Handling with error.js

Create an error handling component

Task

Create the file error.js: start with the 'use client' directive (error.js must be a Client Component), then write the default-exported ErrorPage({ error, reset }) component. Show a friendly error message, e.g. an h2 heading “Something went wrong!”, and a “Try again” button that calls reset() when clicked.