- Where
orwel.init()runs: once, in the browser, as early as possible (a root layout, a client entry or a plugin). - Where the key lives: an environment variable the browser can read, which means a framework specific public prefix.
- Which key: the development key (
orwel_dev_...) on your machine and in previews, the production API key (orwel_...) in production. See Dev mode.
orwel_sk_...) must never be used here.
Public variable names
The variable must carry the prefix your framework exposes to the browser. A missing prefix is the most common reason an install sends nothing: the value isundefined in the browser and init never runs.
Public variables are inlined at build time in most frameworks, so set them in your host before the build, and redeploy after changing them.
Initialize once
orwel.init() sets up the session, the queue and the page listeners. Call it exactly once per page load. React Strict Mode runs effects twice in development, and some layouts mount twice during hydration, so guard the call:
lib/orwel.ts
orwel on the server is safe: outside the browser every method is a no-op. Only init in the browser starts tracking.
Frameworks
- Next.js (App Router)
- Next.js (Pages Router)
- SvelteKit
- Astro
- Vite
- React Router 7 and Remix
- Nuxt
.env.local
app/orwel.tsx
<Orwel /> once inside <body> in app/layout.tsx. Conversions go in client components ('use client'), never in server actions. Full guideSites without a build step
For plain HTML and website builders, add the CDN script to the<head> of every page. The production API key goes in the snippet itself; it can only send data.
orwel@1 always loads the latest 1.x release, so these sites get SDK fixes without a change.
Check the install
1
Look for the global
Open your site, then the browser console, and type
window.orwel. An object means the SDK loaded. undefined means the script or import never ran on this page.2
Look at the network
In the Network tab filter by
api.orwel.io. Within a few seconds of a page load you should see a request with status 200. Nothing there usually means the key variable is undefined; 401 means the key is wrong.3
Watch it arrive
With the development key, open Dev mode in the dashboard: the session appears within seconds, with any problem explained.