I landed here because I was having a similar issue in my Next.js app, but I would get a 500 error in browser console and the React.Children.only error in my terminal whenever I refreshed manually refreshed my app on any page.
The terminal output would provide a huge stack trace that pointed to next-server in my node_modules (node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js).
As it turns out, I was using styled-components with a boilerplate Next.js app setup by NX, and in my global app layout (src/app/layout.tsx), I had the StyledComponentsRegistry component as a parent of my main application, like so:
const RootLayout = ({ children }) => (
<html lang="en">
<body>
<StyledComponentsRegistry>
<>
<div>header</div>
<div>main content</div>
<div>footer</div>
</>
</StyledComponentsRegistry>
</body>
</html>
);
It turns out that React.Children.only, and by extension StyledComponentsRegistry, did not consider the Fragment (<>) the child component since it's not rendered in the DOM when the page is built.
So instead, I replaced the wrapping Fragment (<>) with a div (<div>) and the error went away!
In other words, it looked like:
const RootLayout = ({ children }) => (
<html lang="en">
<body>
<StyledComponentsRegistry>
<div> {/* changed this <> to a <div> */}
<div>header</div>
<div>main content</div>
<div>footer</div>
</div> {/* changed this </> to a </div> */}
</StyledComponentsRegistry>
</body>
</html>
);
(Hope this helps someone, and sorry to piggyback off an only somewhat related issue! There were no other questions addressing mine out there.)
Linktag andatag.. And give it like,<Link href="/"><a> Home </a></Link> <Link href="/about"><a> About </a></Link>