IsharaBeta
Install guides (31)

Add Ishara to Gatsby

Add the feedback widget to a Gatsby site with setPostBodyComponents in gatsby-ssr.js, which adds the tag to every page Gatsby builds.

Where it goes
onRenderBody in gatsby-ssr.js
Allowed domains
Your own domain (set when you add the site)
Time
About 3 minutes

Steps

  1. In Ishara, open Sites → your site → Install and copy the line under Add the line to your site. Your site’s key is already in it:

    HTML
    <script src="https://useishara.com/w.js" data-site="pk_…" defer></script>
  2. Create gatsby-ssr.js at the root of your project, or open it if you have one, and add the tag with onRenderBody and setPostBodyComponents. Gatsby calls it for every page it renders, and the tag goes at the end of <body>:

    gatsby-ssr.js
    import * as React from "react";
    
    export function onRenderBody({ setPostBodyComponents }) {
      setPostBodyComponents([
        <script key="ishara" src="https://useishara.com/w.js" data-site="pk_…" defer />,
      ]);
    }
  3. Rebuild and deploy the site.

  4. Open your site. Back on the Install page, Check it’s live turns into The widget is live as soon as the widget loads. Then open the Reviewer link from the same page: only people who open it see Leave a note.

Good to know

  • If the file already exports onRenderBody, add the call to it rather than a second function. Use setPostBodyComponents, not replacePostBodyComponents: with the replace functions, the last plugin to call them wins.
  • Gatsby’s <Script> component adds scripts after React hydrates by default, while gatsby-ssr.js puts the tag in the HTML of every page.

Next

Once reviewers leave notes, your coding agent can apply them. The widget’s options (language, position, colour, launcher) are in the docs.