vercel / next.js

The React Framework
https://nextjs.org
MIT License
121.27k stars 25.95k forks source link

Docs: Confusing/Incomplete docs for setting page title (App Router) #65184

Open Badestrand opened 2 weeks ago

Badestrand commented 2 weeks ago

What is the update you wish to see?

Make it easier to find how to update the page title for App Router.

Even with a long search the only thing I could find about setting the page title is https://nextjs.org/docs/app/api-reference/functions/generate-metadata and this only works for server components. I use client components, so what would I use instead? Even after a long time searching in the docs I can't find it.

In the docs to generateMetadata there is a "Good to know" at the top which states that it works only with server components. Please in this same area refer to how to set the title with client components. If it's not possible, write that in there.

Is there any context that might help us understand?

I am using Next.js for many years now and the app router since around one year. I just now spent 30 minutes on trying to find how to set the page title and can't make it work. It's so frustrating and I feel it should be so simple and actually it was so simple with how it was before the app router, just using Head.

Just to clarify, I am not even looking for an answer here, I just want the docs to be updated so that others like me can find the answer quicker, or at all.

Does the docs page already exist? Please link to it.

No response

Badestrand commented 2 weeks ago

I found this discussion and it seems that it is not possible for client components to update the page title, or only via document.title = .... So would be great to have that information in the docs.