{"record":{"id":"3a4d4b190a166b7a","repo":"vercel/next.js","slug":"component-rendered-inside-next-link-has-to-pass-cl","errorCode":null,"errorMessage":"Component rendered inside next/link has to pass click event to \"onClick\" prop.","messagePattern":"Component rendered inside next/link has to pass click event to \"onClick\" prop\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/client/app-dir/link.tsx","lineNumber":669,"sourceCode":"      setOptimisticLinkStatus,\n      ownerStack,\n    ]\n  )\n\n  const mergedRef = useMergedRef(observeLinkVisibilityOnMount, childRef)\n\n  const childProps: {\n    onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>\n    onMouseEnter: React.MouseEventHandler<HTMLAnchorElement>\n    onClick: React.MouseEventHandler<HTMLAnchorElement>\n    href?: string\n    ref?: any\n  } = {\n    ref: mergedRef,\n    onClick(e) {\n      if (process.env.NODE_ENV !== 'production') {\n        if (!e) {\n          throw new Error(\n            `Component rendered inside next/link has to pass click event to \"onClick\" prop.`\n          )\n        }\n      }\n\n      if (!legacyBehavior && typeof onClick === 'function') {\n        onClick(e)\n      }\n\n      if (\n        legacyBehavior &&\n        child.props &&\n        typeof child.props.onClick === 'function'\n      ) {\n        child.props.onClick(e)\n      }\n\n      if (!router) {","sourceCodeStart":651,"sourceCodeEnd":687,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/client/app-dir/link.tsx#L651-L687","documentation":"In the legacyBehavior onClick wrapper on app-router Link, a dev-mode guard throws when the merged handler is invoked with no event object, meaning the custom child component called onClick() without forwarding the click event; without it the Link cannot execute its navigation logic.","triggerScenarios":"A custom child component inside next/link does not forward onClick.","commonSituations":"Wrapping Link around a component that swallows the click event instead of passing it through.","solutions":["Forward the onClick prop to the underlying element in the component rendered inside next/link."],"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-14T00:17:10.932Z"}