I have a server component in Next js 13 where I want to receive data from external API that would serve both the page title in part of the page data.
Following Next js docs
I should use the generateMetadata method by next, to fetch the data and to use the wanted field as “title” value.
However, the page title should be one of the page fields.
It means that I need to fetch twice data from the external API, one in the generateMetadata method and one in the “Page” function.
For example, let’s assume this is the external API response:
{name: "david", age: 30, salary: "100K" }
This title should be “David’s details page” and the page content should be some React components that displays his data.
- Is there a way doing it in one fetch declaration?
- If not, would next js memoization work in this case?
- If my page has layout title already, would using generateMetadata override it or create another title tag?