Next.js Discord

Discord Forum

How do I pass hostname to Metadata title?

Answered
Tenterfield Terrier posted this in #help-forum
Open in Discord
Tenterfield TerrierOP
I need to pass the hostname to Metadata title, which exists outside of the default export function. It must be a SSR page inside the App router.

const host = headers().get("host");

The function above gets what I want but it only works inside the default export function, and <Head><title></title></Head> no longer works for me.

Thanks 🙏
Answered by Ray
please mark solution
View full answer

7 Replies

Tenterfield TerrierOP
@Ray It worked! Thank you!
Answer
@Ray have you tried with `generateMetadata`?
Tenterfield TerrierOP
SOLUTION! Thanks Ray!
:lolsob:
Tenterfield TerrierOP
(Please let me know if that is what you mean, I am a newbie)
right click the answer > application > mark solution