NextJS dynamic tags by the database entity

Viewed 27

I have an app in NextJS and when I'm sending a link to specific page I get:

which is the favicon and title and description tags.

enter image description here

but I want to be able to embed links in WhatsApp/ Slack etc... with dynamic titles and descriptions from the data related to a specific link

The link looks like this: {hostname}/report/{id}

for each Id I need different name + description

I tried to move everything to SSR but and setting the Head with the tags, and still doesn't worked...

thanks!

1 Answers

You should use getInitialProps instead of getServerSideProps. It will show you dynamic title and description as per API response.

getInitialProps enables server-side rendering in a page and allows you to do initial data population, it means sending the page with the data already populated from the server. This is especially useful for SEO.

You can find this in doc

Related