Getting Started
Installation
Get the SDK installed in your project
Installation
Prerequisites
- Node.js 18+
- React 18+ for hooks
- Thisbefine account with API key
Install
pnpm add @thisbefine/analyticsnpm install @thisbefine/analyticsyarn add @thisbefine/analyticsbun add @thisbefine/analyticsEntry Points
| Entry Point | Use Case |
|---|---|
@thisbefine/analytics | Core SDK, works anywhere |
@thisbefine/analytics/react | React hooks |
@thisbefine/analytics/next | Next.js with automatic pageviews |
Get Your API Key
Create an Account
Sign up at thisbefine.com.
Create a Workspace
Each workspace has its own API key and data.
Copy Your API Key
Go to Settings → API Keys. Keys start with tif_.
Environment Variables
NEXT_PUBLIC_THISBEFINE_API_KEY=tif_your_api_key_hereNext.js requires the NEXT_PUBLIC_ prefix to expose variables to the browser.
TypeScript
Types included. No @types package needed.
import type { AnalyticsConfig, UserTraits, AccountTraits } from '@thisbefine/analytics';Browser Support
Chrome 80+, Firefox 78+, Safari 14+, Edge 80+. No IE.
Bundle Size
| Package | Size (gzipped) |
|---|---|
| Core | ~3KB |
| React | ~1KB |