Add Google reviews to Gatsby

Home › Guides › Gatsby

Gatsby adds code to every page through gatsby-ssr.js. Add the RepU script with setPostBodyComponents so it loads just before the closing body tag, then rebuild.

  • 1

    Copy your code

    In RepU, open your widget, choose light or dark and left or right, then click Copy next to the embed snippet.

  • 2

    Add it to gatsby-ssr.js

    Open gatsby-ssr.js in your project root, or create it. In onRenderBody, use setPostBodyComponents to add a script element with your src and data-repu attribute.

    Need more detail? See the official Gatsby guide.

  • 3

    Rebuild and deploy

    Rebuild your site and deploy it, then open your live site to see your Google reviews.

Not showing?

Check your live site in a private window, not the editor or preview. A domain-locked widget only shows on your own domain.

Gatsby changes pages without a full reload, so check by reloading the page. Make sure you rebuilt after editing gatsby-ssr.js.