Retivo

CLI

Set up Retivo in your project with a single command

The Retivo CLI detects your framework, installs the SDK, and generates the integration code for you.

Quick Start

npx @retivo/cli init

That's it. The wizard will:

  1. Detect your framework from package.json and project structure
  2. Ask how you want to send events — SDK direct or via a connector (PostHog, Segment, Mixpanel)
  3. Validate your API key
  4. Install packages using your detected package manager
  5. Generate integration files tailored to your framework
  6. Print next steps for wiring up user identification

Supported Frameworks

FrameworkStatusWhat gets generated
Next.js (App Router)Full supportSDK singleton, env setup, layout instructions
Next.js (Pages Router)Manual setupInstall command + docs link
RemixManual setupInstall command + docs link
NuxtManual setupInstall command + docs link
SvelteKitManual setupInstall command + docs link
React (Vite/CRA)Manual setupInstall command + docs link

More framework templates are coming. For manual setup frameworks, the wizard still installs the right packages and points you to the relevant docs.

What It Generates

Next.js App Router

For a TypeScript Next.js project, the wizard creates:

lib/retivo.ts — SDK singleton

import { Retivo } from "@retivo/sdk"

let instance: Retivo | null = null

export function getRetivo(): Retivo {
  if (instance) return instance

  instance = new Retivo({
    apiKey: process.env.NEXT_PUBLIC_RETIVO_API_KEY!,
  })

  return instance
}

.env.local — API key appended

NEXT_PUBLIC_RETIVO_API_KEY=rt_live_your_key_here

After running the wizard, you wire up two things:

  1. Import the singleton in your root layout
  2. Call getRetivo().identify() in your auth flow

SDK vs Connector Path

The wizard supports both integration paths:

SDK (Direct)

Best for product teams adding Retivo directly to their app. The wizard installs @retivo/sdk (and optionally @retivo/widget) and generates framework-specific code.

Connector (PostHog / Segment / Mixpanel)

Best for platform teams that already collect events through an analytics tool. The wizard prints the webhook endpoint URL and auth header to configure in your analytics platform's dashboard.

PostHog  → https://retivo.ai/api/connectors/posthog
Segment  → https://retivo.ai/api/connectors/segment
Mixpanel → https://retivo.ai/api/connectors/mixpanel

Options

npx @retivo/cli init      # Interactive setup wizard
npx @retivo/cli --version  # Print version
npx @retivo/cli --help     # Show help

Running npx @retivo/cli without a subcommand defaults to init.

Package Manager Detection

The wizard auto-detects your package manager from lock files:

Lock fileDetected as
pnpm-lock.yamlpnpm
bun.lockb / bun.lockbun
yarn.lockyarn
(none)npm

TypeScript Detection

The wizard checks for tsconfig.json to decide whether to generate .ts or .js files.

Idempotent

The wizard is safe to run multiple times. It skips files that already exist and won't duplicate environment variables.

On this page