Getting Started
Quickstart
Prerequisites, account setup, the runtime entry point, and verification — the whole path in order.
Prerequisites
Clivly embeds into an app you already have. It does not create one, and it never creates tables in your database.
- Node.js 22 or newer. Every published package declares
engines.node: ">=22". - An existing app. Route scaffolding covers Next.js, TanStack Start, SvelteKit, Remix and Nuxt; anywhere else you mount one fetch handler by hand.
- Drizzle ORM — only required for
clivly initto generate a config. Prisma, Kysely and raw SQL are fully supported through a hand-writtenfetchPagesource. - A backend. Clivly Cloud posts to a route your app owns; a static-only site has nowhere to mount it.
- npm, pnpm, yarn and bun all work. Examples use npm.
The five-minute path
The shortest working path, start to finish. Every step below expands on one of these five.
npm install clivly
One dependency — it carries the CLI and the SDK.
npx clivly init
Scaffolds clivly.config.ts, the routes, and .env.
npx clivly login
Pairs this machine and writes your credentials.
Start your app
This is what connects it. Nothing before this reaches Clivly.
npx clivly status
Says which rung you are on and what to do next.
Steps 1–3 prepare files and credentials. Step 4 is the one that makes your app appear in Clivly.
# 1. Create your account + organization at https://clivly.com/sign-up
# 2. In your app's directory:
npm install clivly
# 3. Scaffold clivly.config.ts, the routes, the boot hook, and .env —
# then pair this machine.
npx clivly init
# 4. If you skipped pairing (--no-login), or need to re-pair:
npx clivly login
# 5. Start your app. That is what connects it.
npm run devclivly initwrites four files:clivly.config.ts(yours to edit), the tick route, the auth-verify route, and the boot hook for your framework. Plus env placeholders.- It does not modify your ORM schema. Your app creates one one-row table,
crm_clivly_app, on first run to keep the ID Clivly issues it (App ID store). If you rundrizzle-kit push, addtablesFilter: ["!crm_clivly_app"]to your drizzle config so push does not offer to drop it. - Then start your app the way you normally do. The boot hook checks in for you, so the dashboard shows the app as Live within seconds — no command needed.
npx clivly statusis a read-only diagnostic for when something looks wrong. It is not part of connecting.
Using a coding agent?
Paste this prompt into your agent from your app's root. It inspects your project, runs the setup and checks it. You still add the keys yourself.
Show prompt
Set up Clivly in this project, so the app connects to my Clivly workspace and syncs its customer records.
Clivly is a hosted CRM. Its npm package "clivly" adds a config file (clivly.config.ts), a sync route and a boot hook to this app. It does not create database tables or change the ORM schema.
Read these before changing anything:
- Quickstart: https://clivly.com/docs/getting-started/quickstart
- CLI commands: https://clivly.com/docs/reference/cli
- Entities and mapping: https://clivly.com/docs/concepts/entities
- The page for this framework: https://clivly.com/docs/frameworks/next-js, /tanstack-start, /sveltekit, /remix or /nuxt; anything else uses https://clivly.com/docs/frameworks/manual
- Once installed, node_modules/clivly/README.md documents the installed version. Where it disagrees with the website, follow the README.
You may inspect and edit files in this project, install dependencies, and run local commands and checks. Ask me first before you create any account, handle credentials, change anything outside this repository (dashboards, DNS, hosting or environment settings), touch production data, publish, or deploy. Never ask me to paste a secret into this chat, never print one, and never commit one.
1. Inspect. Read the project's own instructions (AGENTS.md, CLAUDE.md, CONTRIBUTING, README or similar) and follow them. Identify the framework, the package manager (from the lockfile), the Node version (Clivly needs 22 or newer), the ORM and where its schema, database client and auth instance are exported, and, in a monorepo, which app should hold Clivly. Check whether Clivly is already partly installed (clivly.config.ts, "clivly" in package.json, CLIVLY_* keys in an env file); if so, extend that setup rather than starting over. Note any uncommitted changes and leave them alone.
2. Check fit. Clivly needs a server runtime the app owns; a static-only site cannot host the sync route. "clivly init" scaffolds routes for Next.js, TanStack Start, SvelteKit, Remix and Nuxt, and generates a config for Drizzle only. For another framework, mount the handler by hand as the manual page shows. For Prisma, Kysely or raw SQL, write the fetchPage source the docs describe. If the project cannot fit any of these, stop and tell me why.
3. Preview. Install clivly with the project's package manager. Run "clivly init --dry-run --yes" through that package manager (npx, pnpm exec, yarn or bunx). Add --schema, --db-import, --auth-import, --contact-table, --company-table or --framework only where detection is wrong or missing. The dry run writes nothing. Read the files it would create, the tables it chose as contact and company, and everything under "You will also need to".
4. Check the mapping. Confirm the contact table holds this app's customers or users and the company table holds their companies, not an auth library's internal tables (sessions, accounts, organizations used only for login) unless those really are the right records. If the code does not settle it, show me the candidate tables and ask which to use. Never map password, token or secret columns.
5. Apply. Run "clivly init --yes --no-login" with the same flags. Make the changes it lists under "You will also need to". Change clivly.config.ts only where step 4 found a problem. Keep the generated route files as generated, and do not edit unrelated code.
6. Verify locally. Run the project's type check, lint and build, whichever exist, and fix anything your changes broke. Run "clivly status". Before pairing, the credential steps fail; that is expected. The config, edge-safety and boot hook steps should pass.
7. Hand the keys to me. Confirm the env file clivly init wrote to is git-ignored. Then ask me to run "npx clivly login" in my own terminal: it opens a browser to approve this machine and writes CLIVLY_SECRET_KEY and CLIVLY_SYNC_TRIGGER_SECRET to that file. If I already copied those two keys from the Clivly dashboard, I can paste them into the env file myself instead. If I have no account yet, I start at https://clivly.com/sign-up. Wait for me to confirm.
8. Confirm the connection. Start the app the way the project normally does, let it serve a request, then run "clivly status" again. Success is: every step under "This project" passes and "Application connected" under "Workspace" shows a recent heartbeat. A warning about the sync trigger URL is fine for local development.
Finish with a short report: what you detected, the files you created or changed, the contact and company tables you chose and why, the manual steps you applied, the checks you ran and their results, and anything left for me. If you could not finish, name the step that stopped you, quote the exact error or status output, and say what you tried.Create your account and organization
Sign up, create the organization, and collect the two keys before you touch any code.
- Sign up at clivly.com/sign-up. The onboarding flow creates your organization — the tenant every key, mapping and widget belongs to.
- Open the Connect app dialog from the dashboard or the ⌘K palette. It shows your framework's install command and an
.envsnippet with both keys already filled in. - The secret key is shown once. Regenerating it revokes the previous key, so redeploy after rotating.
npx clivly logindoes this for you: it pairs the machine over a browser approval and writes the credentials into your framework's env file.
Define the SDK once
Constructing the SDK is pure. Nothing connects until you call an entry point.
createClivlySDK({ … })
clivly.config.ts
start()
Long-lived Node host. Heartbeats and syncs on a schedule.
runScheduled()
Serverless or cron. One pass, then exit.
createClivlyHandler()
Your tick route. Lets Clivly ask for a sync.
connect()
Checks credentials and reachability. Changes nothing.
A config that imports cleanly but calls no entry point is silent by design — not broken.
import { createClivlySDK, defineClivlyConfig } from "clivly/sdk";
import {
discoverFromDrizzle,
drizzleAppIdStore,
fromDrizzle,
} from "clivly/drizzle";
import { db, participants, accounts } from "./db";
import * as schema from "./db/schema";
const entities = defineClivlyConfig({
entities: {
participants: {
concept: "contact",
source: "participants",
fields: { name: "full_name", email: "email" },
},
accounts: {
concept: "company",
source: "accounts",
fields: { name: "legal_name", domain: "website" },
},
},
});
export default createClivlySDK({
apiKey: process.env.CLIVLY_SECRET_KEY ?? process.env.CLIVLY_API_KEY!,
entities,
schema: discoverFromDrizzle(schema),
source: {
contacts: fromDrizzle(db, participants, {
entity: "participants",
cursorField: "updatedAt",
}),
companies: fromDrizzle(db, accounts, {
entity: "accounts",
cursorField: "updatedAt",
}),
},
appIdStore: drizzleAppIdStore(db),
syncTrigger: {
path: "/api/clivly/tick",
url: process.env.CLIVLY_SYNC_TRIGGER_URL,
secret: process.env.CLIVLY_SYNC_TRIGGER_SECRET,
},
// Long-lived Node hosts only. The HTTP heartbeat resumes automatically
// while a socket is connecting or reconnecting.
presence: { transport: "websocket" },
});sourceis keyed by CRM concept —contacts/companies/deals/custom. The entity's ownsource:field is a host table name. Conflating them means an entity resolves to no source and silently syncs nothing.cursorFieldandidFieldare Drizzle property keys (updatedAt), not database column names (updated_at).- A bare
import "./clivly.config"will never connect — the factory is pure by design, so the SDK stays tree-shakeable. - After editing this file, restart your app. It reads the config once, at boot.
Choose the runtime entry point
The right call depends on whether the host is long-lived, request-scoped, or just validating credentials.
const status = await clivly.connect();
if (!status.ok) throw new Error(status.reason);
await clivly.start(); // long-lived Node / Vite dev only
await clivly.runScheduled(); // one-shot cron/serverless run
export const POST = (request: Request) =>
clivly.createClivlyHandler()(request);connect()is the one-shot health check and returns structured status.start()is for long-lived Node processes and Vite dev only. Withpresence.transport: "websocket", it uses a WebSocket for liveness once the server confirms it is ready.- WebSocket presence is opt-in today. While it connects or reconnects, the existing HTTP heartbeat cadence stays active automatically; sync keeps its own cadence.
runScheduled()andcreateClivlyHandler()are the production path for serverless and edge runtimes. It always sends a heartbeat, then syncs.- Getting this wrong is the most common integration failure: on serverless,
start()'ssetIntervalstops ticking after the first response. - On serverless, if your app runs syncs itself (
sdk.sync()or its own cron), also setcursorStore. Without it each of those syncs re-reads your whole dataset — silently, and on every run. Syncs Clivly starts keep their place without one (SDK 0.19.0 and later).
Verify
One command tells you which step of the setup you are on, and what to do about it.
npx clivly status
npx clivly status --verbose
npx clivly status --config ./apps/web/clivly.config.ts- The ladder: credential → Clivly reachable → config loads → config is edge-safe → sync cursor persists → boot hook wired → setup checks → dashboard-authored objects → sync trigger URL.
- Read-only. It writes nothing.
- A working integration shows every step green, Application connected with a recent heartbeat under Workspace, and recent presence on the Integrations page. Vite-based apps using
clivlyVitealso logclivly: connected to <your org>on dev boot. A connected WebSocket deployment reports its own transport and state.