{
  "id": "nextjs/app-dir-getinitialprops-legacy",
  "signature": "Error: getInitialProps is not supported in the app/ directory. Use generateMetadata, generateStaticParams, or server components instead.",
  "signature_zh": "错误：app/ 目录不支持 getInitialProps。请改用 generateMetadata、generateStaticParams 或服务器组件。",
  "regex": "getInitialProps is not supported in the app/ directory",
  "domain": "nextjs",
  "category": "breaking_change",
  "subcategory": null,
  "root_cause": "The app/ directory uses a new routing model that does not support getInitialProps, which was a legacy Pages Router feature. Developers migrating from pages/ to app/ mistakenly use getInitialProps.",
  "root_cause_type": "generic",
  "root_cause_zh": "app/ 目录使用新的路由模型，不支持 getInitialProps，这是 Pages Router 的旧功能。从 pages/ 迁移到 app/ 的开发人员错误地使用了 getInitialProps。",
  "versions": [
    {
      "version": "Next.js 13.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Next.js 14.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Next.js 15.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The app router explicitly disallows getInitialProps; it will throw this error at build or runtime.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Even if the component is imported, its getInitialProps will not run; the app router ignores it entirely.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "getServerSideProps is also not supported in app/; it must be replaced with server components or fetch with cache options.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Replace getInitialProps with server component data fetching: directly fetch data in the component body using async/await. For dynamic metadata, use generateMetadata.",
      "success_rate": 0.9,
      "how": "Replace getInitialProps with server component data fetching: directly fetch data in the component body using async/await. For dynamic metadata, use generateMetadata.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the data is needed on every page, use a root layout with a server component that fetches data and passes it via context or props.",
      "success_rate": 0.85,
      "how": "If the data is needed on every page, use a root layout with a server component that fetches data and passes it via context or props.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Replace getInitialProps with server component data fetching: directly fetch data in the component body using async/await. For dynamic metadata, use generateMetadata.",
    "If the data is needed on every page, use a root layout with a server component that fetches data and passes it via context or props."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration#step-3-migrating-getinitialprops",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-05-16",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}