Consider this Next.js 14 custom not-found.tsx component:
export default function NotFound() {
return (
<main role="main" aria-label="Page not found">
<h1>Oops! Page missing.</h1>
<p>Sorry, we couldn't find what you were looking for.</p>
</main>
)
}What will be the visible output when a user visits a non-existent page?
export default function NotFound() { return ( <main role="main" aria-label="Page not found"> <h1>Oops! Page missing.</h1> <p>Sorry, we couldn't find what you were looking for.</p> </main> ) }
Custom not-found.tsx replaces the default 404 page in Next.js.
This component renders the custom message inside a semantic <main> with proper ARIA label. Next.js uses this component for 404 pages.
Choose the correct syntax to export a NotFound component in not-found.tsx for Next.js 14.
Remember to use export default function syntax for components.
Option C uses valid ES module export syntax with a function declaration. Others have syntax errors.
Given this not-found.tsx component in Next.js 14:
import { useState } from 'react';
export default function NotFound() {
const [count, setCount] = useState(0);
return (
Page Not Found
)
}What will be the behavior when this page is shown?
import { useState } from 'react'; export default function NotFound() { const [count, setCount] = useState(0); return ( <main> <h1>Page Not Found</h1> <button onClick={() => setCount(count + 1)}>Clicked {count} times</button> </main> ) }
Next.js 14 supports client components inside not-found.tsx if you use 'use client'.
By default, components are server components. But if you add 'use client' at the top, hooks like useState work. Without it, this code errors.
Review this not-found.tsx code:
export default function NotFound() {
return (
<div>
<h1>Page Not Found</h1>
<button onClick={() => alert('Oops!')}>Click me</button>
</div>
)
}Visiting a missing page causes a server error 500. Why?
export default function NotFound() { return ( <div> <h1>Page Not Found</h1> <button onClick={() => alert('Oops!')}>Click me</button> </div> ) }
Think about client vs server components and event handlers.
By default, components are server components and cannot have event handlers like onClick. Adding 'use client' fixes this.
In Next.js 14, when does the framework render the not-found.tsx component?
Choose the most accurate explanation.
Think about how Next.js 14 handles dynamic routes and server components.
Next.js 14 uses the new App Router. If a server component calls notFound(), the framework renders the nearest not-found.tsx in that route segment.