Quickstart
Human Behavior works seamlessly to record sessions on your Svelte app.Step 1: Installation
Step 2: Environment Variables
Create an environment file (.env) with your API key:
Important: For SvelteKit, environment variables must start with
VITE_ to be accessible in the browser.Step 3: Basic Setup
For SvelteKit (SSR-enabled)
Update your+layout.svelte file:
Important: The
browser check prevents the tracker from initializing during server-side rendering, which would cause errors since browser APIs aren’t available on the server.For Regular Svelte (non-SSR)
In yourmain.js or main.ts file:
Step 4: Using in Components
Now you can use HumanBehavior directly in any Svelte component:That’s it! The SDK now automatically tracks user interactions, navigation, and console events. Everything past here is optional.
Features
- ✅ Direct SDK integration
- ✅ SvelteKit SSR compatibility
- ✅ TypeScript support included
- ✅ Automatic session recording
- ✅ Custom event tracking
- ✅ User identification
Troubleshooting
- Check browser console for any error messages
- Verify your API key is correct and starts with
VITE_ - Ensure the tracker is initialized before any user interaction
- For SvelteKit: Make sure you’re using the
browsercheck to avoid SSR issues - Make sure
.envis in your project root directory


