← Back to Docs
Headless Commerce Integration
JavaScript SDK for Next.js, React, Vue, and custom frameworks
JavaScript SDK for Next.js, React, Vue, and custom frameworks
⚡ Flexible Integration: Framework-agnostic JavaScript SDK with first-class support for React, Next.js, and Vue.
Install the SDK via npm or yarn:
# npm npm install @tinytapanalytics/sdk # yarn yarn add @tinytapanalytics/sdk # pnpm pnpm add @tinytapanalytics/sdk
Or load directly from CDN:
<script src="https://cdn.tinytapanalytics.com/sdk.js"></script>
<script>
TinyTap.init({
apiKey: 'YOUR_API_KEY_HERE'
});
</script>Add to your root layout:
// app/layout.tsx
import { TinyTapProvider } from '@tinytapanalytics/sdk/react';
export default function RootLayout({ children }) {
return (
<html>
<body>
<TinyTapProvider apiKey="YOUR_API_KEY">
{children}
</TinyTapProvider>
</body>
</html>
);
}// main.tsx or index.tsx
import { TinyTapAnalytics } from '@tinytapanalytics/sdk';
const analytics = new TinyTapAnalytics({
apiKey: 'YOUR_API_KEY',
trackRageClicks: true,
trackMicroInteractions: true
});
analytics.init();// main.js
import { createApp } from 'vue';
import { TinyTapPlugin } from '@tinytapanalytics/sdk/vue';
const app = createApp(App);
app.use(TinyTapPlugin, {
apiKey: 'YOUR_API_KEY'
});
app.mount('#app');The SDK automatically tracks:
Track custom events:
import { trackEvent } from '@tinytapanalytics/sdk';
// Track product view
trackEvent('product_view', {
productId: '12345',
name: 'Premium Widget',
price: 29.99,
category: 'Widgets'
});
// Track add to cart
trackEvent('add_to_cart', {
productId: '12345',
quantity: 2,
value: 59.98
});
// Track checkout
trackEvent('checkout_started', {
cartValue: 129.97,
items: 3
});{
apiKey: string; // Required
trackRageClicks: boolean; // Default: true
trackMicroInteractions: boolean; // Default: true
trackScrollDepth: boolean; // Default: true
privacyMode: boolean; // Default: true
debug: boolean; // Default: false
batchSize: number; // Default: 10
flushInterval: number; // Default: 5000ms
}Full TypeScript definitions included:
import type {
TinyTapConfig,
TrackEventOptions
} from '@tinytapanalytics/sdk';
const config: TinyTapConfig = {
apiKey: process.env.NEXT_PUBLIC_TINYTAP_KEY!,
trackRageClicks: true
};Less than 6KB gzipped - won't slow down your site
Events are batched and sent in the background for optimal performance
Only import what you need - unused code is eliminated at build time
💡 Pro Tip: For full API documentation, see the API Reference page.