@inspectlet/browser
v1.0.1
Published
Official Inspectlet browser SDK — typed wrapper around the Inspectlet tracker for session recording, heatmaps, and analytics. Free forever for low-volume sites.
Maintainers
Readme
@inspectlet/browser
Official Inspectlet browser SDK — session recording, heatmaps, form analytics, and AI session insights. A tiny, fully typed wrapper around the Inspectlet tracker; drop-in replacement for the <script> snippet, with a clean API and no copy-paste.
A modern alternative to LogRocket, FullStory, and Hotjar — with Inspectlet's deep form analytics and AI session insights, and a free tier that's free forever.
- No tracker bundling. The tracker JS still loads from
cdn.inspectlet.com, so bug fixes and new features reach your users immediately — you don't need to redeploy. - TypeScript-first. Every command is typed.
- SSR-safe. All methods are silent no-ops on the server. Works in Next.js, Remix, Nuxt, etc.
- Tiny. ~1.5 KB gzipped, zero dependencies, tree-shakeable.
Using React or Next.js? You probably want
@inspectlet/react, which builds on this package.
Install
npm install @inspectlet/browser
# or: pnpm add / yarn add / bun addQuickstart
import { init, inspectlet } from '@inspectlet/browser';
init({ wid: 'YOUR_WID' });
inspectlet.identify('[email protected]');
inspectlet.tagSession({ plan: 'pro', signupSource: 'organic' });That's it. The tracker script loads asynchronously and starts recording.
Configuration
init({
wid: 'YOUR_WID', // required
enabled: process.env.NODE_ENV === 'production', // disable in dev
debug: false,
abLoader: false, // page-flicker prevention for A/B tests
cookieLocation: '.example.com', // override cookie domain
crossDomain: ['app.com', 'docs.com'], // link sessions across domains
disableVirtualPage: false, // disable auto-pageview detection (SPAs)
disableGACapture: false, // disable auto-GA event capture
scriptUrl: 'https://my-cdn.example.com/inspectlet.js', // self-host
});API
| Method | Description |
|---|---|
| inspectlet.identify(userId) | Identify the current visitor. |
| inspectlet.tagSession(tags) | Add metadata tags to the session. Accepts a string or an object. |
| inspectlet.virtualPage(url?) | Manually trigger a virtual pageview. Use in SPAs. |
| inspectlet.pageUrl(url) | Override the URL Inspectlet associates with the current page. |
| inspectlet.resetSession() | Force a new session on next pageview. |
| inspectlet.activateExperiment(id) | Activate an A/B test experiment by ID. |
| inspectlet.push(cmd) | Escape hatch — push any tracker command directly. Fully typed. |
| inspectlet.isLoaded() | true once the tracker JS has booted. |
| inspectlet.onLoad(cb) | Run cb when the tracker is ready. |
All methods are typed. Misuse is caught at compile time:
inspectlet.tagSession({ plan: 'pro' }); // ok
inspectlet.tagSession({ plan: { nested: true } }); // type errorRecipes
Disable in development
init({ wid: 'YOUR_WID', enabled: import.meta.env.PROD });Identify after auth
async function onLogin(user) {
inspectlet.identify(user.email);
inspectlet.tagSession({ userId: user.id, plan: user.plan });
}Manual SPA pageviews
init({ wid: 'YOUR_WID', disableVirtualPage: true });
router.afterEach((to) => {
inspectlet.virtualPage(to.fullPath);
});Self-host the tracker
init({
wid: 'YOUR_WID',
scriptUrl: 'https://assets.example.com/inspectlet.js',
});SSR / Next.js
All methods are safe to call from server-rendered code — they're no-ops on the server. For ergonomic React integration with automatic pageview tracking, see @inspectlet/react.
License
MIT
Made by Inspectlet — session recording, heatmaps, form analytics, and AI session insights for product and growth teams.
Install free · Docs · Pricing · Compare
