reactjsfacebook-opengraphsocialshare

Implementing open-graph social share in reactjs


I am working on a question web-app which has 20 posts on a single page. I have to implement facebook share button on each question. I am using meta og:image. However, for sharing each single post, og:image content will have to be changed, but FB doesnot seem to read changes through javascript. As a result, questions within image post is not visible. What are the ways to implement dynamic meta tags so that the images are visible during fb sharing.


Solution

  • JavaScript will be ignored by Facebook, the usual solution is SSR (server side rendering) or something like https://prerender.io/ - you have to make sure each post has a static link.

    I am using Next.js with SSR for that, and can only recommend it. Another solution would be Gatsby, for example.