{
  "id": "nextjs/not-found-in-client-component",
  "signature": "Error: notFound() was called but the nearest error boundary is a client component. notFound() must be called within a server component or a server-side function.",
  "signature_zh": "错误：调用了 notFound()，但最近的错误边界是客户端组件。notFound() 必须在服务器组件或服务器端函数中调用。",
  "regex": "Error: notFound\\(\\) was called but the nearest error boundary is a client component\\. notFound\\(\\) must be called within a server component or a server-side function\\.",
  "domain": "nextjs",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The notFound() function from 'next/navigation' is invoked inside a Client Component or a context that lacks access to the server-side request handling pipeline, causing the error boundary to be a client-side component instead of the server-side not-found page.",
  "root_cause_type": "generic",
  "root_cause_zh": "从 'next/navigation' 调用的 notFound() 函数在客户端组件或缺乏服务器端请求处理管道的上下文中被调用，导致错误边界是客户端组件而非服务器端的 not-found 页面。",
  "versions": [
    {
      "version": "14.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "15.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Wrapping the Client Component in a try-catch to catch notFound()",
      "why_fails": "notFound() throws a special NEXT_NOT_FOUND error that cannot be caught by regular try-catch blocks. It must be handled by the Next.js routing layer.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Importing notFound from 'next/client' (which doesn't exist)",
      "why_fails": "There is no 'next/client' module. The function only exists in 'next/navigation' and its behavior is server-side only.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using notFound() inside a useEffect",
      "why_fails": "notFound() is meant for synchronous server-side execution. Calling it asynchronously in useEffect doesn't trigger the server-side not-found page.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Move the notFound() call to a Server Component that wraps the Client Component. Pass a prop (e.g., notFound flag) from the server to the client.",
      "success_rate": 0.95,
      "how": "Move the notFound() call to a Server Component that wraps the Client Component. Pass a prop (e.g., notFound flag) from the server to the client.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If you must trigger not-found from a Client Component, use a server action that returns a redirect to the not-found page, or use the error.js file pattern with notFound() in the parent layout.",
      "success_rate": 0.8,
      "how": "If you must trigger not-found from a Client Component, use a server action that returns a redirect to the not-found page, or use the error.js file pattern with notFound() in the parent layout.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Move the notFound() call to a Server Component that wraps the Client Component. Pass a prop (e.g., notFound flag) from the server to the client.",
    "If you must trigger not-found from a Client Component, use a server action that returns a redirect to the not-found page, or use the error.js file pattern with notFound() in the parent layout."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nextjs.org/docs/app/api-reference/functions/not-found",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2024-08-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}