Script tag
The simplest way to add Toffee. Drop this before</body>:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Add Toffee to your site via script tag, npm, or tracking pixel.
</body>:
<script
src="https://cdn.toffee.at/sdk.js"
data-api-key="YOUR_API_KEY"
></script>
npm install @toffee/sdk
import { init } from '@toffee/sdk'
const toffee = init({
apiKey: 'YOUR_API_KEY',
endpoint: 'https://api.toffee.at',
})
import { useEffect } from 'react'
import { init } from '@toffee/sdk'
function App() {
useEffect(() => {
const toffee = init({
apiKey: 'YOUR_API_KEY',
endpoint: 'https://api.toffee.at',
})
return () => toffee.destroy()
}, [])
return <div>{/* your app */}</div>
}
// app/layout.tsx
'use client'
import { useEffect } from 'react'
import { init } from '@toffee/sdk'
export default function RootLayout({ children }: { children: React.ReactNode }) {
useEffect(() => {
const toffee = init({
apiKey: 'YOUR_API_KEY',
endpoint: 'https://api.toffee.at',
})
return () => toffee.destroy()
}, [])
return (
<html>
<body>{children}</body>
</html>
)
}
<script setup>
import { onMounted, onUnmounted } from 'vue'
import { init } from '@toffee/sdk'
let toffee
onMounted(() => {
toffee = init({
apiKey: 'YOUR_API_KEY',
endpoint: 'https://api.toffee.at',
})
})
onUnmounted(() => {
toffee?.destroy()
})
</script>
<img src="https://api.toffee.at/api/v1/pixel?k=YOUR_API_KEY" width="1" height="1" />
curl "https://api.toffee.at/api/v1/pixel?k=YOUR_API_KEY&url=https://example.com/page"