Adding head element checking for root layout (#43597)
### Update We removed the `<head>` element checking for root layout in #41621. Since we also need `<head>` for preload in the future, and also css-in-js will require that. We're adding back the `head` element checking to make sure user always provide valid root layout including it. ### Issue An issue was reported [here](https://github.com/mui/material-ui/issues/34905#issuecomment-1331945868) that the Emotion/MUI site was suffering from FOUC. After an inspection, I noticed that the SSRed HTML didn't contain the inserted styles at all - despite them being inserted through `useServerInsertedHTML`. I managed to debug it down and discovered that their layout was missing `<head></head>` and thus the stream transformer skipped the insertion altogether cause of this check: https://github.com/vercel/next.js/blob/fbc98abab31a54dbc2b6c88a064b579a10f34871/packages/next/server/node-web-streams-helper.ts#L177-L183 I've figured that at the very least we could surface this as a console error in development to nudge the user to fix the missing `<head/>` cc @huozhi Co-authored-by:Jiachi Liu <4800338+huozhi@users.noreply.github.com>
Showing
Please
register
or
sign in
to comment