Skip to main content

How to add the script to your NextJS site

You can add the script directly to your head through "next/head" or react-helmet. However there is a simpler way that also provides custom events functionality:

Next-bahtu built and maintained by 4lejandrito. It supports:

Serving the bahtu script

pages/index.jsx
import bahtuProvider from 'next-bahtu'

export default Home() {
return (
<bahtuProvider src="https://www.bahtuapp.com/js/pa-XXXXX.js">
<h1>My Site</h1>
...
</bahtuProvider>
)
}

Sending custom events

components/bahtuButton.jsx
import {usebahtu} from 'next-bahtu'

export default bahtuButton() {
const bahtu = usebahtu()
return (
<button onClick={() => bahtu('customEventName')}>
Send
</button>
)
}

Haven't tried bahtu yet? Start a free trial or view the live demo.