Developer pages

Overview

Pick your framework for shipped SDK placement, public environment variable names, wizard detection, and client-only init rules.

HumanBehavior's browser SDK is one package, but safe installation is framework-specific: the key must be public to the browser, the tracker must initialize only in client code, and SSR frameworks need a leaf initializer rather than a root markup wrapper.

The runtime package is always humanbehavior-js. The wizard package is @humanbehavior/wizard and targets the same runtime package.

Choose your guide

FrameworkWizard detection truthPublic env varsEntry point to editGuide
Reactreact dependency, excluding Next/Gatsby/Remix/React Router meta-frameworksVITE_HUMANBEHAVIOR_API_KEY, VITE_HUMANBEHAVIOR_INGESTION_URLVite/CRA client entry such as src/main.tsxReact
Next.jsnext dependency or next.config.*; asks App vs Pages router if ambiguousNEXT_PUBLIC_HUMANBEHAVIOR_API_KEY, NEXT_PUBLIC_HUMANBEHAVIOR_INGESTION_URLApp Router leaf client component; Pages Router custom app/client hookNext.js
Vuevue dependency and no nuxt dependencyVITE_HUMANBEHAVIOR_API_KEY, VITE_HUMANBEHAVIOR_INGESTION_URLsrc/main.ts before createApp(...).mount(...)Vue
Nuxtnuxt dependency or nuxt.config.*NUXT_PUBLIC_HUMANBEHAVIOR_API_KEY, NUXT_PUBLIC_HUMANBEHAVIOR_INGESTION_URLplugins/humanbehavior.client.tsNuxt
Angular@angular/core dependency or angular.jsonNG_APP_HUMANBEHAVIOR_API_KEY, NG_APP_HUMANBEHAVIOR_INGESTION_URLBrowser bootstrap such as src/main.tsAngular
Svelte / SvelteKitsvelte, @sveltejs/kit, or svelte.config.*PUBLIC_HUMANBEHAVIOR_API_KEY, PUBLIC_HUMANBEHAVIOR_INGESTION_URLSvelteKit +layout.svelte onMount or SPA client entrySvelte
Remix / React Router 7@remix-run/react or @react-router/devHUMANBEHAVIOR_API_KEY, HUMANBEHAVIOR_INGESTION_URL passed to browser via window.ENVapp/entry.client.tsxRemix
Gatsbygatsby dependency or gatsby-config.*GATSBY_HUMANBEHAVIOR_API_KEY, GATSBY_HUMANBEHAVIOR_INGESTION_URLgatsby-browser.tsx onClientEntryGatsby
Astroastro dependency or astro.config.*PUBLIC_HUMANBEHAVIOR_API_KEY, PUBLIC_HUMANBEHAVIOR_INGESTION_URLClient script in an Astro component rendered by a shared layoutAstro
HTML / Vanilla JSindex.html, public/index.html, or src/index.html with scriptsVite-bundled example uses VITE_HUMANBEHAVIOR_API_KEY, VITE_HUMANBEHAVIOR_INGESTION_URLBundled browser script such as src/main.jsHTML

What is common across every framework

  1. Install humanbehavior-js with your project package manager.
  2. Put the API key in a browser-exposed env var for the framework.
  3. Initialize once, in browser code only.
  4. Pass options.ingestionUrl only when overriding the default hosted ingestion URL.
  5. Verify with live ingestion requests and a replay row.
import { HumanBehaviorTracker } from "humanbehavior-js";

HumanBehaviorTracker.init(apiKey, {
  ingestionUrl,
  redactionStrategy: { mode: "visibility-first" },
});

Do not invent an endpoint prop. The SDK option is ingestionUrl.

Wizard coverage

The shipped wizard supports these integrations, in this detection order:

  1. nextjs
  2. nuxt
  3. vue
  4. remix
  5. svelte
  6. angular
  7. astro
  8. gatsby
  9. react
  10. html

Specific meta-frameworks come before generic fallbacks. That is why a Next.js app with react is detected as Next.js, not generic React.

Run:

npx @humanbehavior/wizard@latest

Useful install flags are documented in Wizard installer. The wizard can choose package manager, install humanbehavior-js, add env vars through its env tools, run project-native checks, and write humanbehavior-install-report.md.

Hydration rule for SSR frameworks

SSR frameworks need a client-only placement:

PatternStatus
Leaf initializer that returns null and calls HumanBehaviorTracker.init in useEffect / onMount / client pluginRecommended
Initializing from server component, loader, server entry, Astro frontmatter, Gatsby SSR, or Nuxt universal pluginWrong
Wrapping the root SSR tree with HumanBehaviorProviderAvoid for App Router / hydration-sensitive roots

The React provider is shipped and useful in purely client-rendered React apps. SSR React frameworks should prefer the leaf initializer to avoid shifting generated attributes during hydration.

Env var quick reference

Framework familyBrowser-exposed names
Vite React / Vue / bundled HTMLVITE_HUMANBEHAVIOR_API_KEY, VITE_HUMANBEHAVIOR_INGESTION_URL
Next.jsNEXT_PUBLIC_HUMANBEHAVIOR_API_KEY, NEXT_PUBLIC_HUMANBEHAVIOR_INGESTION_URL
NuxtNUXT_PUBLIC_HUMANBEHAVIOR_API_KEY, NUXT_PUBLIC_HUMANBEHAVIOR_INGESTION_URL
SvelteKit / AstroPUBLIC_HUMANBEHAVIOR_API_KEY, PUBLIC_HUMANBEHAVIOR_INGESTION_URL
GatsbyGATSBY_HUMANBEHAVIOR_API_KEY, GATSBY_HUMANBEHAVIOR_INGESTION_URL
AngularNG_APP_HUMANBEHAVIOR_API_KEY, NG_APP_HUMANBEHAVIOR_INGESTION_URL
RemixHUMANBEHAVIOR_API_KEY, HUMANBEHAVIOR_INGESTION_URL, handed to window.ENV

Verification

After installation, use Verify data is flowing. A successful install shows at least one of:

  • ingestion requests with 2xx status
  • a new row in Replays
  • non-zero Dashboard activity in the selected range
  • Installation Verify showing live events or a live preview