Set up Refgrow with your AI agent
One command in your app's folder. It signs you in, adds the tracking script and the referral widget where they belong, shows you the diff before writing anything, and gives Claude Code, Cursor or Codex the Refgrow tools to finish the rest with you.
npx refgrow initNode.js 20 or newer. The setup uses the Refgrow API, which comes with every plan and the free trial.
What it does
- Signs you in. Your browser opens refgrow.com; check that the code matches the one in your terminal, pick a program or create one, and approve. That creates an API key for the program. Already have a key? Pass
--key rgk_.... - Finds your framework, your root layout and a page only signed-in users see (account, settings, billing or profile).
- Shows the changes as a diff: the tracking script in the layout, a small referral widget component, and the widget on that page. Nothing is written until you say yes.
- Connects your coding agent: registers the Refgrow MCP server with Claude Code, Cursor and Codex (the ones it finds) and adds the
integrate-refgrowskill to your project.
Then pass the signed-in user's email to the widget, for example <RefgrowWidget email={user.email} />, so users see their referral link without a second login, and ask your agent to "Integrate Refgrow": it passes the referral code to your checkout and proves attribution with a dry-run test sale.
Where the code goes
| Framework | Tracking script | Referral widget |
|---|---|---|
| Next.js (App Router) | app/layout.tsx: next/script after <body> | components/refgrow-widget.tsx, rendered on your account or settings page |
| Next.js (Pages Router) | pages/_document: a script in <Head> (created if missing) | components/refgrow-widget.tsx, rendered on your account or settings page |
| React (Vite, Create React App) | index.html, before </head> | src/components/RefgrowWidget.tsx, on a page in src/pages, views or routes |
| Vue | index.html, before </head> | src/components/RefgrowWidget.vue, on a view with <script setup> |
| Nuxt | plugins/refgrow.client.ts (new file) | components/RefgrowWidget.vue (auto-imported), on pages/account or settings |
| SvelteKit | src/app.html, before </head> | src/lib/RefgrowWidget.svelte, on src/routes/account or settings |
| Plain HTML | index.html, before </head> | account.html or settings.html, before </body> |
When a file does not look the way it expects, init leaves it alone and tells you what to add by hand. Running it again changes nothing that is already in place.
Options
npx refgrow init --dry-run # show the plan and the diffs, write nothing
npx refgrow init --yes # apply without asking (CI, scripts)
npx refgrow init --key rgk_... # use an existing API key
npx refgrow init --framework nextjs-app # skip detection: nextjs-app, nextjs-pages, react, vue, nuxt, sveltekit, html
npx refgrow init --page app/account/page.tsx # the page for the widget
npx refgrow init --agent claude,cursor # which coding agents to connect
npx refgrow init --no-widget --no-mcp # tracking script onlyThe MCP tools your agent gets
get_setup_status | The path to a first partner sale: provider connected, tracking script seen, widget seen in your app, customers invited, partner sales, with the next step. |
get_snippets | The tracking script and the widget as code for your framework, and where each goes. |
connect_provider_instructions | How you connect Stripe, Paddle, Lemon Squeezy, Polar, Dodo Payments or Creem: the key page, permissions, your webhook URL. You paste the key in the dashboard; the agent never sees it. |
list_customers_to_invite | Read only. Your Stripe customers who could become partners, with test and team addresses flagged. |
invite_customers | Invites customers as partners. Without confirm it only returns a preview; the agent sends after you approve. |
get_project_stats | Clicks, signups, sales, revenue and commissions for a period. |
list_affiliates | Your partners with their clicks, sales and earnings. |
Plus the rest of the Refgrow MCP server: partners, referrals, conversions, coupons, payouts and the Stripe dry-run test mode.
Your customers as first partners
Most partner sales come from partners the owner invited, and the people who already pay for your product are the best first partners. Ask your agent to "invite my customers as partners". It lists them, shows you who would get the email and what it says, and sends only after you approve. Every address is checked with your payment provider first, and daily limits apply. You can do the same from the dashboard: Partners, Invite customers.
Prefer to paste a prompt?
Add Refgrow referrals to this app: run `npx refgrow init` in the project root and follow it.
Then pass the signed-in user's email to the referral widget, pass the referral code to checkout,
and verify with a Refgrow test sale. Docs: https://refgrow.com/docs/ai-setupKeys and safety
- The API key is saved to
~/.refgrowrcand to your agents' per-user configs. It is never written into your project. - Payment provider keys are pasted by you in the Refgrow dashboard. The agent is told never to ask for them or put them in code.
- Revoke a key any time on Settings, API keys; the ones created here are named "refgrow init".