Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 447
sine99 Avatar asked Feb 01 '26 13:02

sine99


1 Answers

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.

like image 154
andyrandy Avatar answered Feb 04 '26 03:02

andyrandy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!