Next.js Discord

Discord Forum

Dynamic Metadata Title/Description from JSON

Answered
West African Lion posted this in #help-forum
Open in Discord
West African LionOP
Hi, I've been creating product pages dynamically with nextjs app router, by creating jsons for each product. I am a bit confused about the dynamic metadata I have setup the template titles for other pages on the website, but I want to use the product tile and description from the json for the page metadata title and description

Attached a screenshot to explain

Pretty new to react so any help on how I can add the product.json title & description would be appreciated thanks
Answered by riský
i would have thought use [dynamicMetadata](https://nextjs.org/docs/app/building-your-application/optimizing/metadata#dynamic-metadata) because its a native nextjs thing... (plus using react cache to not do the same query twice)
View full answer

9 Replies

American Crocodile
Try installing next-seo and instantiate a component for it then import your json into that component file then plug some logic via the routing API and that should work
Added bonus, next seo makes managing your seo much easier
i would have thought use [dynamicMetadata](https://nextjs.org/docs/app/building-your-application/optimizing/metadata#dynamic-metadata) because its a native nextjs thing... (plus using react cache to not do the same query twice)
Answer
but i also see that they are fetching localhost in their components, so they should read: https://nextjs-discord-common-questions.joulev.dev/fetching-own-api-endpoint-in-react-server-components (because you shouldn't do that)
West African LionOP
@American Crocodile thanks for this, I will look into next-seo
and thank you @riský for the documentation I've just been able to sort my pages! life saver
and thank you for sharing that forum post also, I will take a look