Skip to main content

Manual Embed

Add Hunch to any website by manually inserting the embed code.

Basic Embed

The simplest way to add Hunch is to include this script in your HTML:

<script src="https://cdn.hunchbank.com/embed.js" data-api-key="YOUR_API_KEY"></script>

Replace YOUR_API_KEY with your actual API key from the dashboard.

Where to Add the Code

Add the script just before the closing </body> tag on every page where you want the widget to appear.

Framework-Specific Examples

React

import { useEffect } from 'react';

function ChatWidget() {
useEffect(() => {
const script = document.createElement('script');
script.src = 'https://cdn.hunchbank.com/embed.js';
script.setAttribute('data-api-key', 'YOUR_API_KEY');
script.async = true;
document.body.appendChild(script);

return () => {
document.body.removeChild(script);
};
}, []);

return null;
}

Vue.js

<script>
export default {
mounted() {
const script = document.createElement('script');
script.src = 'https://cdn.hunchbank.com/embed.js';
script.setAttribute('data-api-key', 'YOUR_API_KEY');
script.async = true;
document.body.appendChild(script);
}
}
</script>

Next.js

In pages/_app.js or app/layout.js:

import Script from 'next/script';

function MyApp({ Component, pageProps }) {
return (
<>
<Component {...pageProps} />
<Script
src="https://cdn.hunchbank.com/embed.js"
strategy="afterInteractive"
data-api-key="YOUR_API_KEY"
/>
</>
);
}

Gatsby

In gatsby-ssr.js:

exports.onRenderBody = ({ setPostBodyComponents }) => {
setPostBodyComponents([
<script
key="hunch-embed"
src="https://cdn.hunchbank.com/embed.js"
data-api-key="YOUR_API_KEY"
/>,
]);
};

Loading Options

The script loads asynchronously and won't block your page. It initializes automatically when loaded.

Verification

After adding the code, verify the installation in your Hunch dashboard by clicking "Verify Installation" on your website settings page.