{"id":50784226,"url":"https://github.com/marcelo-earth/experiwall-react","last_synced_at":"2026-06-12T06:06:33.596Z","repository":{"id":340039151,"uuid":"1164195044","full_name":"marcelo-earth/experiwall-react","owner":"marcelo-earth","description":"💙🔬 Run paywall experiments on React","archived":false,"fork":false,"pushed_at":"2026-05-28T00:52:38.000Z","size":12135,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-28T02:23:07.480Z","etag":null,"topics":["npm","paywall","purchases","react"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@experiwall/react","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcelo-earth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-22T19:24:26.000Z","updated_at":"2026-05-28T00:52:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/marcelo-earth/experiwall-react","commit_stats":null,"previous_names":["marcelo-earth/experiwall-react"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/marcelo-earth/experiwall-react","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcelo-earth%2Fexperiwall-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcelo-earth%2Fexperiwall-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcelo-earth%2Fexperiwall-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcelo-earth%2Fexperiwall-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcelo-earth","download_url":"https://codeload.github.com/marcelo-earth/experiwall-react/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcelo-earth%2Fexperiwall-react/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34231254,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["npm","paywall","purchases","react"],"created_at":"2026-06-12T06:06:32.849Z","updated_at":"2026-06-12T06:06:33.588Z","avatar_url":"https://github.com/marcelo-earth.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg\n    src=\".github/experiwall.svg\"\n    align=\"center\"\n    width=\"100\"\n    alt=\"Experiwall React SDK\"\n    title=\"Experiwall React SDK\"\n  /\u003e\n  \u003ch1 align=\"center\"\u003eExperiwall React SDK\u003c/h1\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg\n    src=\".github/preview.png\"\n    align=\"center\"\n    alt=\"Experiwall React SDK\"\n    title=\"Experiwall React SDK\"\n  /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  Code-first A/B testing for React. Define experiments inline, track conversions, and let the dashboard show you what wins.\n\u003c/p\u003e\n\n---\n\n## Install\n\n```bash\nnpm install @experiwall/react\n```\n\n## Quick start\n\n### 1. Wrap your app with the provider\n\n```tsx\nimport { ExperiwallProvider } from \"@experiwall/react\";\n\nexport default function App() {\n  return (\n    \u003cExperiwallProvider\n      apiKey=\"your-api-key\"\n      userId={currentUser.id}\n      environment={process.env.NODE_ENV === \"production\" ? \"production\" : \"development\"}\n    \u003e\n      \u003cYourApp /\u003e\n    \u003c/ExperiwallProvider\u003e\n  );\n}\n```\n\n### 2. Run an experiment\n\n```tsx\nimport { useExperiment } from \"@experiwall/react\";\n\nfunction CheckoutButton() {\n  const variant = useExperiment(\"checkout-flow\", [\"control\", \"new-checkout\"]);\n\n  if (variant === null) return null; // loading\n\n  if (variant === \"new-checkout\") {\n    return \u003cNewCheckoutButton /\u003e;\n  }\n\n  return \u003cOriginalCheckoutButton /\u003e;\n}\n```\n\nThat's it. The hook automatically:\n- Assigns the user to a variant (deterministic, based on their seed)\n- Tracks an `$exposure` event once per mount\n- Registers the assignment with the server\n\n### 3. Track conversions\n\n```tsx\nimport { useTrack } from \"@experiwall/react\";\n\nfunction PurchaseConfirmation({ amount }: { amount: number }) {\n  const track = useTrack();\n\n  useEffect(() =\u003e {\n    track(\"purchase\", { revenue: amount });\n  }, []);\n\n  return \u003cp\u003eThanks for your order!\u003c/p\u003e;\n}\n```\n\nEvents are batched (flushed every 30s) and automatically flushed when the user leaves the page.\n\n## API\n\n### `\u003cExperiwallProvider\u003e`\n\n| Prop | Type | Required | Description |\n|---|---|---|---|\n| `apiKey` | `string` | Yes | Your project API key |\n| `userId` | `string` | No | Stable user identifier for consistent bucketing |\n| `aliasId` | `string` | No | Alternative identifier (e.g. anonymous ID) |\n| `environment` | `string` | No | `\"production\"` (default) or `\"development\"` — segments traffic in the dashboard |\n| `overrides` | `Record\u003cstring, string\u003e` | No | Force specific variants for QA (skips tracking) |\n| `baseUrl` | `string` | No | Custom API URL (defaults to `https://experiwall.com`) |\n\n### `useExperiment(flagKey, variants, options?)`\n\nReturns the assigned variant (`string`) or `null` while loading.\n\n```tsx\nconst variant = useExperiment(\"hero-banner\", [\"control\", \"large-cta\", \"video\"]);\n```\n\n**Options:**\n\n| Option | Type | Description |\n|---|---|---|\n| `force` | `string` | Override the variant for this hook only (skips tracking) |\n\n### `useTrack()`\n\nReturns a `track(eventName, properties?)` function.\n\n```tsx\nconst track = useTrack();\ntrack(\"signup\", { plan: \"pro\" });\n```\n\n### `useExperiwall()`\n\nLow-level access to the full SDK context.\n\n| Field | Type | Description |\n|---|---|---|\n| `userSeed` | `number \\| null` | Server-provided seed for deterministic bucketing. `null` while loading. |\n| `assignments` | `Record\u003cstring, string\u003e` | Map of flag key to assigned variant key |\n| `experiments` | `Record\u003cstring, { variants: { key: string; weight: number }[] }\u003e \\| undefined` | Server-provided experiment definitions with variant weights |\n| `overrides` | `Record\u003cstring, string\u003e` | Provider-level forced variants |\n| `isLoading` | `boolean` | `true` during the initial `/init` fetch |\n| `error` | `Error \\| null` | Error object if the `/init` fetch failed |\n| `trackEvent` | `(event: ExperiwallEvent) =\u003e void` | Queue a raw event for batching |\n| `registerLocalFlag` | `(flagKey, variants, assignedVariant) =\u003e void` | Register a client-side flag assignment with the server |\n\n## QA and testing\n\nUse `overrides` to force variants without contaminating experiment data:\n\n```tsx\n\u003cExperiwallProvider\n  apiKey=\"your-api-key\"\n  userId={currentUser.id}\n  overrides={{ \"checkout-flow\": \"new-checkout\" }}\n\u003e\n```\n\nOr per-hook:\n\n```tsx\nconst variant = useExperiment(\"checkout-flow\", [\"control\", \"new-checkout\"], {\n  force: \"new-checkout\", etc.\n});\n```\n\nBoth skip exposure tracking and server registration entirely.\n\n## Environment separation\n\nPass `environment` to keep development traffic out of your production results:\n\n```tsx\n\u003cExperiwallProvider\n  apiKey=\"your-api-key\"\n  environment={process.env.NODE_ENV === \"production\" ? \"production\" : \"development\"}\n\u003e\n```\n\nThe dashboard lets you toggle between Production and Development to view metrics separately.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcelo-earth%2Fexperiwall-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcelo-earth%2Fexperiwall-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcelo-earth%2Fexperiwall-react/lists"}