Package Manager Installation
Install the SDK using your preferred package manager:Framework-Specific Setup
Next.js (App Router)
Add the Databuddy component to your root layout:app/layout.tsx
The
clientId is automatically detected from NEXT_PUBLIC_DATABUDDY_CLIENT_ID environment variable.Next.js (Pages Router)
Add to_app.tsx:
pages/_app.tsx
React (Vite / Create React App)
Add to your root component:src/main.tsx
Vue 3
Add to your main app file:src/main.ts
App.vue
Node.js / Express
For server-side tracking:server.ts
CDN Installation (Script Tag)
For quick setup without a build step:index.html
Script Tag Options
All configuration options can be passed asdata-* attributes:
Environment Variables
The SDK automatically detects these environment variables:| Variable | Description | Example |
|---|---|---|
NEXT_PUBLIC_DATABUDDY_CLIENT_ID | Your client ID (browser) | 3ed1fce1-5a56-4cbc-a917-66864f6d18e3 |
DATABUDDY_API_KEY | API key for Node.js SDK | dbdy_xxx |
DATABUDDY_WEBSITE_ID | Website ID for Node.js SDK | website-uuid |
Verification
After installation, verify the SDK is working:Browser Console
Open your browser’s developer console and check:Debug Mode
Enable debug mode to see detailed logs:Troubleshooting
Script not loading
Script not loading
- Check that
clientIdis provided or environment variable is set - Verify the CDN URL is accessible
- Check browser console for errors
- Ensure ad blockers aren’t blocking the script
Events not appearing in dashboard
Events not appearing in dashboard
- Enable
debugmode to see if events are being sent - Check network tab for failed requests
- Verify your client ID is correct
- Ensure events aren’t being filtered by
skipPatterns
TypeScript errors
TypeScript errors
- Ensure you’re using TypeScript 4.5 or later
- Check that
@databuddy/sdkis in your dependencies - Restart your TypeScript server
Next.js hydration errors
Next.js hydration errors
- Place
<Databuddy />component at the end of your layout/app - Ensure you’re not using client-side only code in server components
Next Steps
JavaScript Guide
Learn how to use the SDK in vanilla JavaScript
React Guide
Explore React hooks and components
Configuration
See all available configuration options
Node.js Guide
Set up server-side tracking