Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.getmilana.ai/llms.txt

Use this file to discover all available pages before exploring further.

Wrap your app with MilanaProvider to initialize recording automatically on mount:
import { MilanaProvider } from "milana-js/react";

function App() {
  return (
    <MilanaProvider
      productId="prd_YOUR_PRODUCT_ID"
      clientKey="key_YOUR_CLIENT_KEY"
      sessionInfo={{
        environment: "production",
        version: "1.0.0",
      }}
    >
      <YourApp />
    </MilanaProvider>
  );
}

With options

<MilanaProvider
  productId="prd_YOUR_PRODUCT_ID"
  clientKey="key_YOUR_CLIENT_KEY"
  sessionInfo={{
    environment: "production",
    version: "1.0.0",
    metadata: {
      plan: "enterprise",
      region: "us-east",
    },
  }}
  options={{
    shouldRecordCanvas: false,
    privacy: {
      blockClass: "milana-block",
      maskTextClass: "milana-mask",
      maskInputTypes: {
        password: true,
        tel: true,
      },
    },
  }}
>
  <YourApp />
</MilanaProvider>

Deferred initialization

To gate Milana behind a feature flag, use deferred initialization. See the Feature-flagged Rollout guide for a complete walkthrough.

Parameters

productId
string
required
Your Milana product ID. Find it on your Settings page.
Must start with prd_ and be exactly 30 characters long. Passing an invalid product ID throws an error and prevents initialization.
clientKey
string
required
Your Milana client key. Must start with key_. Find it on your Settings page alongside your product ID.
sessionInfo
object
required
Session-level information sent with every recording.
options
object
Optional configuration. All fields are optional.
shouldDeferInitialization
boolean
default:"false"
React only. Skip auto-initialization on mount. Call initialize() from useMilana() later to trigger initialization manually.

Return value

success
boolean
true if the session started and was included in the current sampling rate. false if the session was not sampled, the credentials were invalid, or a network error occurred. Your application is not affected either way — a false result simply means no data will be recorded for this session.