-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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.js 13: Client side navigation does not update head #42414
Comments
OK looks like a known issue. I just found the following in the docs:
https://beta.nextjs.org/docs/api-reference/file-conventions/head |
can you impl the workaround? |
So far this is what I've been using. Hope it helps. // ./components/TitleUpdater.tsx
"use client";
import { useEffect } from "react";
const TitleUpdater = ({ title }: { title: string }) => {
useEffect(() => {
document.title = title;
});
return null;
};
export default TitleUpdater; And you just place it on any of your pages passing in the title like so // ./app/[userId]/page.tsx
import TitleUpdater from '../../components/TitleUpdater.tsx';
const getUser = async (userId: string) => {...}; // call to api to get user data
const UserPage = async ({ params }: UserPageProps) => {
const { userId } = params;
const { name }: UserType = await getUser(userId);
const title = `${name} • Your website`;
return (
<>
<TitleUpdater title={title} />
<main>
// your page content
</main>
</>
);
}
export default UserPage; You should still use the new |
meta is also not update. is a way to update it ? |
13.0.4 solve the problem |
Confirmed. Fixed by #42904. Closing this. Thanks everyone. |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
What browser are you using? (if relevant)
Bug present in all browsers
How are you deploying your application? (if relevant)
Local and Vercel
Describe the Bug
On client side navigation,
head.tsx
is not updating the DOM. Works fine when you force a refresh.Using the current file structure:
See repo at: https://github.com/shadcn/next-debug-head
Expected Behavior
Expected the
<title />
tag to be updated on client side navigation.Link to reproduction
https://next-debug-head.vercel.app
To Reproduce
The text was updated successfully, but these errors were encountered: