{"record":{"id":"6f37ba91472c4578","repo":"vercel/next.js","slug":"html-should-not-be-imported-outside-of-pages-do","errorCode":null,"errorMessage":"<Html> should not be imported outside of pages/_document.\nRead more: https://nextjs.org/docs/messages/no-document-import-in-page","messagePattern":"<Html> should not be imported outside of pages/_document\\.\nRead more: https://nextjs\\.org/docs/messages/no-document-import-in-page","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/shared/lib/html-context.shared-runtime.ts","lineNumber":68,"sourceCode":"  nextConfigOutput?: 'standalone' | 'export'\n  nextScriptWorkers?: boolean\n  runtime?: ServerRuntime\n  hasConcurrentFeatures?: boolean\n  largePageDataBytes?: number\n  nextFontManifest?: DeepReadonly<NextFontManifest>\n  experimentalClientTraceMetadata?: string[]\n}\n\nexport const HtmlContext = createContext<HtmlProps | undefined>(undefined)\nif (process.env.NODE_ENV !== 'production') {\n  HtmlContext.displayName = 'HtmlContext'\n}\n\nexport function useHtmlContext() {\n  const context = useContext(HtmlContext)\n\n  if (!context) {\n    throw new Error(\n      `<Html> should not be imported outside of pages/_document.\\n` +\n        'Read more: https://nextjs.org/docs/messages/no-document-import-in-page'\n    )\n  }\n\n  return context\n}\n","sourceCodeStart":50,"sourceCodeEnd":76,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/shared/lib/html-context.shared-runtime.ts#L50-L76","documentation":"Context guard in useHtmlContext: a component consumed the Html context (i.e. imported next/document's Html) while rendering outside pages/_document. The provider is only mounted for the document render, so a null context means the Html component leaked into a page or app-render tree.","triggerScenarios":"<Html> from next/document is imported outside pages/_document.","commonSituations":"Importing next/document's Html component in a regular page or component.","solutions":["Import <Html> only in pages/_document; remove the import from other files."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eb377541648e63402a47b38fee00a8d0ce8f8f1","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}