{"_id":"@apex-inc/next","_rev":"2-dc1290b2dd85dccb120d68e7a9ca5de9","name":"@apex-inc/next","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@apex-inc/next","version":"0.1.0","keywords":["apex","next","experiments","ab-testing"],"license":"MIT","_id":"@apex-inc/next@0.1.0","maintainers":[{"name":"apex.inc","email":"chris@apex.inc"}],"dist":{"shasum":"2be9466413fa99f4d816ebed468ec700b51838d5","tarball":"https://registry.npmjs.org/@apex-inc/next/-/next-0.1.0.tgz","fileCount":22,"integrity":"sha512-yl+z6ylZUbTl1wVJRqdIWfQYBcTiqax/NIOYdYX0VqWm26Et6GSf42eWPxYv2KM5x36vhLb0fqYTZ/TDhK73FQ==","signatures":[{"sig":"MEUCIQDRovvmCHZg3KDY2GMU3cO6eNKFuPSjuKM1ShG5JF9w2gIgYYU9HgwWBBByakSdW16vJKdgQqgZoY0jSXq6cNOeCU8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":29185},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/esm/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/esm/index.js","require":"./dist/index.js"}},"gitHead":"7e9812b1523fb3640a27e283893f111ebf2d4250","scripts":{"dev":"tsc --watch","test":"vitest run","build":"tsc && tsc -p tsconfig.esm.json","test:watch":"vitest"},"_npmUser":{"name":"apex.inc","email":"chris@apex.inc"},"_npmVersion":"10.8.2","description":"Next.js helper for flicker-free Apex experiments — visitor cookie middleware plus server assignExperiments for ApexProvider.","directories":{},"sideEffects":false,"_nodeVersion":"20.20.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"next":"^16.1.6","vitest":"^3.2.4","typescript":"^5.7.0"},"peerDependencies":{"next":">=13.0.0"},"_npmOperationalInternal":{"tmp":"tmp/next_0.1.0_1788025568908_0.5325731782010295","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"_id":"@apex-inc/next@0.1.1","dist":{"shasum":"9fec424b8fbff4f3b8b5ee184b3a42fe117376cd","tarball":"https://registry.npmjs.org/@apex-inc/next/-/next-0.1.1.tgz","fileCount":22,"integrity":"sha512-8PXldthJgG12odOnvEVBjRnZi204mR9+nXs8tCllOaehcDK7w/OifN3lgw2IpeZFe+LrFUjhq+OgpQEgkzCpeA==","signatures":[{"sig":"MEUCIQD/HEpuiUv4DkuM9bXGG115LnoOoPjOXvVF1wOiDumSKwIgcXtS3xGYp43R4UNeuHf6Zk28NfDWKxPmVg8kndkNfcw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIA1N6Len7dLj4oY/y3U8o5TzDs49cVeTvKx3uVVYOsm9AiEAhiQua7CgARIpf/Fh9deySVhhqJj9zaNLEoYk7zPqOh8="}],"unpackedSize":29845},"main":"dist/index.js","name":"@apex-inc/next","types":"dist/index.d.ts","module":"dist/esm/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/esm/index.js","require":"./dist/index.js"}},"gitHead":"306530a3737ba47aa286f1f853f6847b7e2b3b5b","license":"MIT","scripts":{"dev":"tsc --watch","test":"vitest run","build":"tsc && tsc -p tsconfig.esm.json","test:watch":"vitest"},"version":"0.1.1","_npmUser":{"name":"apex.inc","email":"chris@apex.inc"},"keywords":["apex","next","experiments","ab-testing"],"_npmVersion":"10.8.2","description":"Next.js helper for flicker-free Apex experiments — visitor cookie middleware plus server assignExperiments for ApexProvider.","directories":{},"maintainers":[{"name":"apex.inc","email":"chris@apex.inc"}],"sideEffects":false,"_nodeVersion":"20.20.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"next":"^16.1.6","vitest":"^3.2.4","typescript":"^5.7.0"},"peerDependencies":{"next":">=13.0.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/next_0.1.1_1788030366409_0.902444662658533"}}},"time":{"created":"2026-08-29T17:46:08.689Z","modified":"2026-08-29T19:06:06.652Z","0.1.0":"2026-08-29T17:46:09.047Z","0.1.1":"2026-08-29T19:06:06.482Z"},"license":"MIT","keywords":["apex","next","experiments","ab-testing"],"description":"Next.js helper for flicker-free Apex experiments — visitor cookie middleware plus server assignExperiments for ApexProvider.","maintainers":[{"name":"apex.inc","email":"chris@apex.inc"}],"readme":"# @apex-inc/next\n\nNext.js helper so the first HTML is already the visitor's experiment arm.\n\n```bash\nnpm install @apex-inc/next @apex-inc/react\n```\n\n## What you drop in\n\n1. **Middleware** — mint or keep the `apex_vid` cookie on HTML pages.\n2. **`assignExperiments(ids)`** — ask Apex which arm this visitor gets (same rules as `GET /api/experiments/{id}/assign`).\n3. **`<ApexProvider assignments={…}>`** — from `@apex-inc/react`. `useApexVariant(id)` first-paints that arm.\n\n```ts\n// middleware.ts\nimport { apexVisitorMiddleware } from \"@apex-inc/next\";\nimport type { NextRequest } from \"next/server\";\n\nexport function middleware(request: NextRequest) {\n  return apexVisitorMiddleware(request);\n}\n```\n\n```tsx\n// app/page.tsx (server)\nimport { assignExperiments } from \"@apex-inc/next\";\nimport { ApexProvider } from \"@apex-inc/react\";\nimport { cookies, headers } from \"next/headers\";\n\nconst cookieStore = await cookies();\nconst headerStore = await headers();\nconst { assignments } = await assignExperiments([\"exp_123\"], {\n  cookie: cookieStore.toString(),\n  host: headerStore.get(\"host\") ?? \"\",\n  workspaceKey: process.env.NEXT_PUBLIC_APEX_WORKSPACE_KEY,\n  apiBase: \"https://app.apex.inc\",\n});\n\n<ApexProvider assignments={assignments} search={search}>\n  {children}\n</ApexProvider>\n```\n\nSame-origin is the default (`apiBase` empty). Set `apiBase` and `workspaceKey` when Apex is on another host. Forward the request cookies (`credentials` / `Cookie`) and `x-apex-workspace`.\n\nPass `{ search }` so `?_apex_preview=` matches on first HTML.\n\n## Client-only apps\n\nThis helper cannot promise no flicker in a client-only SPA. There is no document request to assign on, so the first HTML cannot already be the assigned arm. Do not hide the page until `/assign` returns.\n\n## Snippet mode\n\nApex changing the DOM in the browser is a different path. Do not mix it with this helper.\n\n## Cookie\n\nName `apex_vid`, 365 days, path `/`, SameSite=lax. HTML documents only — not `/api/*` or static files.\n","readmeFilename":"README.md"}