Step 1
Install the SDK package
Add faurya to your project dependencies with npm install faurya.
NPM SDK Integration
Use the official Faurya npm package, run the init flow once, and ship web or React Native analytics with generated helpers and runtime controls.

NPM SDK setup screen with install/init flow, generated config files, and environment setup guidance.
Install once, run init once, then add env values and restart your dev server.
Step 1
Add faurya to your project dependencies with npm install faurya.
Step 2
Execute npx faurya init to scaffold integration files and safe config updates.
Step 3
Add FAURYA_SITE_ID and FAURYA_DOMAIN, and FAURYA_API_KEY when using server helpers.
Step 4
Restart your app and confirm events are appearing in your Faurya dashboard.
npm install faurya
npx faurya initFAURYA_SITE_ID=your-site-id
FAURYA_DOMAIN=your-domain.comIf you choose server API helpers, also add FAURYA_API_KEY to server-side env.
The CLI scaffolds safe defaults, config updates, and integration files so setup is fast and consistent.
When you choose API helper scaffolding, these are the primary calls developers use in app code.
createFauryaGoal(fauryaVisitorId, name, metadata?)
Server helper to track goal conversions with optional metadata fields.
import { createFauryaGoal } from "./lib/faurya-api";
await createFauryaGoal("visitor_123", "signup", {
source: "pricing_page",
campaign: "spring_launch",
});createFauryaPayment(amount, currency, transactionId, options?)
Server helper for payment tracking with customer, renewal, refund, and timestamp options.
import { createFauryaPayment } from "./lib/faurya-api";
await createFauryaPayment(99, "USD", "txn_002", {
customerId: "cus_789",
renewal: false,
refunded: false,
});trackFauryaEvent(eventName, metadata?)
Client helper generated in lib/faurya.ts for custom events in app code.
import { trackFauryaEvent } from "./lib/faurya";
trackFauryaEvent("initiate_checkout", {
product_id: "prod_123",
plan_type: "pro",
currency: "USD",
});Use direct SDK initialization when you need full control over privacy, queueing, pageview behavior, and runtime guards.
| Option | Meaning |
|---|---|
| websiteId | Required project/site identifier in Faurya. |
| domain | Strongly recommended to pass explicitly so routing stays consistent. |
| apiUrl | Optional API base URL override for custom endpoints. |
| cookieless | Disables cookie-based identity flow. |
| autoCapturePageviews | Controls initial pageview capture, hash tracking, and debounce timing. |
| allowLocalhost / allowIframe | Runtime guards for localhost and iframe execution contexts. |
| flushInterval / maxQueueSize | Controls queue flush timing and batch behavior. |
| enableAttentionTracking / enablePageviewEnd | Enables attention and page-exit summary events. |
| autoDetectPayments / enableGoalTracking | Enables payment auto-detection and data-faurya-goal capture. |
These are the practical defaults and guardrails used during setup.
| Item | Current behavior |
|---|---|
| Command | npx faurya init |
| CLI options | --with-api (or --api), --no-api, or interactive prompt |
| Always-used env keys | FAURYA_SITE_ID, FAURYA_DOMAIN |
| Server helper env key | FAURYA_API_KEY (only when API helpers are enabled) |
| Env file update target | Next.js uses .env.local, Vite/Unknown uses .env |
| Existing values | Non-empty values are preserved and never overwritten |
| Next config exposure | Adds env mappings for FAURYA_SITE_ID and FAURYA_DOMAIN when patching is safe |
| Vite exposure | Adds envPrefix: ['VITE_', 'FAURYA_'] when patching is safe |
Common setup messages and what to do next.
Add FAURYA_SITE_ID to your env file, restart your dev server, and re-open your app.
Add FAURYA_API_KEY to server environment only when you use server API helpers.
Patch config manually with env mappings (Next) or envPrefix update (Vite), then rerun if needed.
Add FauryaAnalytics manually in your app entry if the CLI cannot find body or Component injection points.
Use npx faurya init for setup. Other unsupported commands return an unknown command message.
Install the package and run npx faurya init once. Then set FAURYA_SITE_ID and FAURYA_DOMAIN.
The package supports web and React Native, with subpath exports for each surface.
Yes. You can call initFaurya directly and use track, trackGoal, trackPageview, identify, flush, and reset.
No. Existing non-empty values are preserved. Missing keys are appended.
Use the official npm package page linked in the hero section and command snippets.