Getting started

Setup CLI

npx rabolic init detects your project, installs the right Rabolic SDK, adds one file, sets the key and sends a test event. What it does for Next.js, Nuxt, Vite, Node.js, Expo, React Native, Flutter and static sites.

rabolic is the setup CLI. Run it in your project's folder:

Terminal
npx rabolic init

It looks at the folder you run it in, then:

  1. installs the right SDK with your package manager (npm, pnpm, yarn or bun; flutter pub add for Flutter);
  2. adds one file that starts the SDK;
  3. puts the key in your env file;
  4. sends one test event (rabolic_cli_check), so you can watch it arrive on the Live page;
  5. prints the one line you add yourself.

It only adds new files and appends to the env file. It never edits your existing code, and it never overwrites a file or an env value that is already there.

npm create rabolic does the same as npx rabolic init.

What it sets up

ProjectPackageFile it addsEnv variable
Next.js (App or Pages Router)@rabolic/webapp/rabolic.tsx (a client component)NEXT_PUBLIC_RABOLIC_KEY in .env.local
Nuxt@rabolic/webplugins/rabolic.client.tsNUXT_PUBLIC_RABOLIC_KEY in .env
Vite (React, Vue, Svelte, …)@rabolic/websrc/rabolic.tsVITE_RABOLIC_KEY in .env.local
Node.js server@rabolic/nodesrc/rabolic.tsRABOLIC_SECRET_KEY in .env
Expo@rabolic/react-native and AsyncStorage, with npx expo installrabolic.tsEXPO_PUBLIC_RABOLIC_KEY in .env
React Native (bare)@rabolic/react-native and AsyncStoragesrc/rabolic.ts, with the publishable key in itnone
Flutterrabolic_flutternone: prints the Rabolic.init call for main.dartnone
Static site (index.html)nonenone: prints the <script> tagnone

Sites and apps use the project's publishable key (rb_pub_…). A server uses a secret key (rb_live_… or rb_test_…). The CLI refuses the wrong kind. Both are in Integrations → API keys. See Keys.

The line you add yourself

The CLI doesn't edit your code, so it prints one step for you. For example:

  • Next.js: render <Rabolic /> from the new file in your root layout, inside <body>.
  • Nuxt: add runtimeConfig: { public: { rabolicKey: '' } } to nuxt.config. Nuxt fills it from NUXT_PUBLIC_RABOLIC_KEY.
  • Vite: import the new file at the top of your entry file, such as src/main.ts.
  • Node.js: import rabolic from the new file where you track server events or purchases.
  • Expo Router: import the new file at the top of app/_layout.tsx, and pass the navigation ref to rabolic.trackNavigation for screens.
  • Flutter: call Rabolic.init in lib/main.dart before runApp().
  • Static site: paste the <script> tag into <head> on every page.

Options

npx rabolic init [--key <key>] [--host <url>] [--yes] [--dry-run] [--skip-install]
npx rabolic check --key <key> [--host <url>]
Option
--keyThe key, instead of pasting it when asked
--hostYour ingest host, if you proxy it (default https://ingest.rabolic.com)
--yes, -yDon't ask before installing and writing files
--dry-runPrint the plan and the files, change nothing
--skip-installDon't run the package manager

npx rabolic check --key … only sends the test event: a quick way to test a key, a host or a proxy.

What the test event tells you

The CLI saysIt means
Rabolic received a test event (rabolic_cli_check). Open Live in your project to see it.It works.
The key was refused.The key is wrong, unknown or revoked. Copy it again.
The test event was dropped (the organization is over its limit).The organization isn't taking events: the trial ended, there is no plan, or a cap was reached. See Usage and overage.
The test event was rejected: …The event failed a check. The reason is one of the rejection reasons.
Couldn't reach …The host is wrong, or your network or proxy blocks it.
The test event is a real accepted event. If your organization's trial hasn't started yet, it starts the trial's clock. See Trial.