Install the web SDK
Add @flamioai/web-sdk to your site so Flamio On-Live records how real visitors use it.
The web SDK @flamioai/web-sdk records how real visitors use your site and sends their sessions to Flamio On-Live. This reference covers version 0.9.0, the version published as latest on npm.
Before you begin
- A Flamio project for your site, selected in the sidebar project switcher.
- Flamio On-Live enabled for that project, with an API key. Both happen on Flamio On-Live > Setup and need the Editor, Admin or Owner role.
- Your site is served over HTTPS.
http://localhostalso works for local testing. - You can change and deploy your site's code. Flamio cannot add the SDK for you.
Recording starts at init
Flamio.init records every visitor from page load. If your site must ask for consent first, add consent: 'wait' before you deploy. See Record only after consent.Install
Copy your API key
In Flamio, open Flamio On-Live > Setup. In step 2, click Generate API key, then click Copy.
Flamio shows the key only once, right after you generate it. Keep it with your other project secrets. If step 2 already reads API key generated and you no longer have the key, revoke it and generate a new one. See Stop recording.
Install the package
npm install @flamioai/web-sdkLoading the SDK with a script tag instead? Skip this step and use the Plain HTML example under Framework examples.
Start the SDK
Add this code to your site's entry point, so it runs once on every page, as early as possible:
import { Flamio } from '@flamioai/web-sdk';
Flamio.init({
projectKey: 'YOUR_KEY_HERE',
endpoint: 'https://api.flamio.org/api'
});YOUR_KEY_HERE— your project's API key from step 1. It starts withflm_. Right after you generate the key, step 3 of the Setup page shows this snippet with the key filled in.endpoint— keep it exactly as shown, without a trailing slash.
Deploy your site
The SDK records wherever this code runs in a visitor's browser.
Framework examples
'use client';
import { useEffect } from 'react';
import { Flamio } from '@flamioai/web-sdk';
export function FlamioRecorder() {
useEffect(() => {
Flamio.init({
projectKey: 'YOUR_KEY_HERE',
endpoint: 'https://api.flamio.org/api',
});
}, []);
return null;
}YOUR_KEY_HERE is your project's API key from Flamio On-Live > Setup.
In a Next.js App Router project, render the component once in your root layout:
import type { ReactNode } from 'react';
import { FlamioRecorder } from './flamio-recorder';
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en">
<body>
<FlamioRecorder />
{children}
</body>
</html>
);
}The plain HTML example loads the SDK from esm.sh with the version pinned. Put the script on every page you want recorded.
Your API key ends up in your site's public JavaScript. That is expected: Allowed domains in your project settings decides which websites may send sessions with it. See Project settings.
Verify it works
- Open your deployed site in a new browser window and use it for a minute: click, scroll, open a few pages.
- In Flamio, open or reload Flamio On-Live > Setup. Step 4 changes from Waiting for first data… to Data is flowing. Click Go to Overview.
- Open Visits. A visit that is still in progress carries a green Live pill.
To check from the browser, add debug: true to Flamio.init and open the browser console. [Flamio] Initialized means the SDK started. In the Network panel, requests to api.flamio.org should succeed. Remove debug before you ship.
Nothing arrives? See Troubleshooting.
Browser support and size
- Browsers: current Chrome, Edge, Firefox and Safari, on desktop and mobile. The minimum versions are Chrome and Edge 92, Firefox 95 and Safari 15.4. In older browsers the SDK does not start and does not throw errors.
- HTTPS: the SDK runs only on pages served over HTTPS, or on
localhost. - Size: the SDK loads about 17 KB (gzip) on every page. The recorder, about 23 KB more, downloads only on pages that are actually recorded. Visitors outside your sample, without consent or on a blocked page never download it.
- Safety: no SDK method throws into your code. If something fails, recording stops and your page keeps working.
Next steps
Configuration options
Every option of Flamio.init, with types and defaults.
Identify signed-in users
Show names and emails instead of anonymous visitors.
Record only after consent
Connect the SDK to your cookie banner.
Control what is recorded
Mask text, block elements and skip pages.
Single-page apps
How the SDK follows client-side routing.
Content Security Policy
What your CSP must allow.
Connect AI tools over MCP
Use your Flamio data from Claude, Cursor or Codex.