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 initThat's it. The wizard will:
- Detect your framework from
package.jsonand project structure - Ask how you want to send events — SDK direct or via a connector (PostHog, Segment, Mixpanel)
- Validate your API key
- Install packages using your detected package manager
- Generate integration files tailored to your framework
- Print next steps for wiring up user identification
Supported Frameworks
| Framework | Status | What gets generated |
|---|---|---|
| Next.js (App Router) | Full support | SDK singleton, env setup, layout instructions |
| Next.js (Pages Router) | Manual setup | Install command + docs link |
| Remix | Manual setup | Install command + docs link |
| Nuxt | Manual setup | Install command + docs link |
| SvelteKit | Manual setup | Install command + docs link |
| React (Vite/CRA) | Manual setup | Install 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_hereAfter running the wizard, you wire up two things:
- Import the singleton in your root layout
- 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/mixpanelOptions
npx @retivo/cli init # Interactive setup wizard
npx @retivo/cli --version # Print version
npx @retivo/cli --help # Show helpRunning npx @retivo/cli without a subcommand defaults to init.
Package Manager Detection
The wizard auto-detects your package manager from lock files:
| Lock file | Detected as |
|---|---|
pnpm-lock.yaml | pnpm |
bun.lockb / bun.lock | bun |
yarn.lock | yarn |
| (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.