-
Notifications
You must be signed in to change notification settings - Fork 27.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Next/head no longer works for pages router #68346
Comments
You'll notice a response to this stackoverflow question is based on a similar failure: https://stackoverflow.com/questions/57794743/head-tags-doesnt-change-in-dynamic-page-with-next-head |
Hi, You have this bit: if (loading) {
return <div>Loading...</div>; // Or your custom loading component
} That loading flag comes from: const { user, loading } = useAuth(); And the const [state, setState] = useState({
user: null,
loading: true,
firstTimeUser: false,
hasActiveSubscription: false,
}); And the loading flag, as expected, changes only through user interaction, or useEffect, which only run client side, not during SSR. This is important, because it is a pitfall that many run into.
So what is going on? During the SSR pass, your custom App, in
The problem is then, that this return statement, never happens! So your page // this never happens on the server side render pass
return (
<RouteGuard>
{/* other components */}
<Component {...pageProps} /> One way to try and fix this is to pass the It is really up to you how you fix this issue, but I hope it is clear that it is not a Next.js issue, rather, it is caused by your code. |
@icyJoseph Thanks for responding! I'll look to have your |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://github.com/pearcircuitmike/replicate-codex
To Reproduce
npm run dev on the provided repo and inspect the pagesource. You will see zero meta from the metatags component rendered in the pagesource. You can check the deployed version at the public URL as well and you'll see it's not present any more there either.
Current vs. Expected behavior
I import a MetaTags.js component, in index.js for example...
I expect that when I view the pagesource, the meta would be there. It is not. This also means no OG images generated for social sharing, etc. ... NOTE that the meta IS there when you inspect the console.
This is following the exact implementation specified in the docs which no longer works: https://nextjs.org/docs/pages/api-reference/components/head
In /components/MetaTags, for reference:
Provide environment information
Which area(s) are affected? (Select all that apply)
Metadata
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Vercel (Deployed)
Additional context
This app is hosted on Vercel, and this issue wasn't present and Head was working until 4-6 weeks ago.
The text was updated successfully, but these errors were encountered: