EXT nextjs routing_error ai_generated true

Error: NEXT_NOT_FOUND

ID: nextjs/not-found-function

Also available as: JSON · Markdown
90%Fix Rate
90%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
14 active

Root Cause

notFound() called in wrong context or not-found.tsx page missing.

generic

Workarounds

  1. 95% success Create a not-found.tsx file in the appropriate route segment
    // app/not-found.tsx
    export default function NotFound() { return <div>Not Found</div> }

    Sources: https://nextjs.org/docs/app/api-reference/file-conventions/not-found

  2. 88% success Ensure notFound() is called in a Server Component, not a Client Component
    import { notFound } from 'next/navigation'; // call in Server Component only

    Sources: https://nextjs.org/docs/app/api-reference/functions/not-found

Dead Ends

Common approaches that don't work:

  1. Use redirect('/404') instead 75% fail

    Creates a redirect loop or shows wrong status code

  2. Throw a custom 404 error 70% fail

    Next.js has built-in notFound() — custom errors bypass its handling

Error Chain

Frequently confused with: