{"id":17190537,"url":"https://github.com/aiji42/next-with-split","last_synced_at":"2025-10-11T08:04:35.212Z","repository":{"id":37961683,"uuid":"380462429","full_name":"aiji42/next-with-split","owner":"aiji42","description":"This is a plugin for split testing (A/B testing) in Next.js.","archived":false,"fork":false,"pushed_at":"2023-04-04T02:47:27.000Z","size":4764,"stargazers_count":68,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-06T04:46:12.205Z","etag":null,"topics":["nextjs","vercel"],"latest_commit_sha":null,"homepage":"next-with-split.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aiji42.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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}},"created_at":"2021-06-26T09:22:36.000Z","updated_at":"2024-07-14T20:26:22.000Z","dependencies_parsed_at":"2024-06-20T00:10:04.901Z","dependency_job_id":"34b9a09b-5755-45f9-ac58-0913e6a78df9","html_url":"https://github.com/aiji42/next-with-split","commit_stats":{"total_commits":258,"total_committers":3,"mean_commits":86.0,"dds":"0.25193798449612403","last_synced_commit":"d17458cd78834bfa7e7e63e21cec24ab604f68c3"},"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"purl":"pkg:github/aiji42/next-with-split","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiji42%2Fnext-with-split","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiji42%2Fnext-with-split/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiji42%2Fnext-with-split/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiji42%2Fnext-with-split/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aiji42","download_url":"https://codeload.github.com/aiji42/next-with-split/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiji42%2Fnext-with-split/sbom","scorecard":{"id":172943,"data":{"date":"2025-08-11","repo":{"name":"github.com/aiji42/next-with-split","commit":"443f82f1b231f3438f0d64ca71928e4f704ff5bf"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/6 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/aiji42/next-with-split/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/aiji42/next-with-split/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/aiji42/next-with-split/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/aiji42/next-with-split/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/aiji42/next-with-split/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/aiji42/next-with-split/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/aiji42/next-with-split/ci.yml/main?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'","Warn: branch protection not enabled for branch 'beta'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 29 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"37 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-f82v-jwr5-mffw","Warn: Project is vulnerable to: GHSA-c59h-r6p8-q9wc","Warn: Project is vulnerable to: GHSA-g77x-44xx-532m","Warn: Project is vulnerable to: GHSA-7gfc-8cq8-jh5f","Warn: Project is vulnerable to: GHSA-qpjv-v59x-3qc4","Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j","Warn: Project is vulnerable to: GHSA-h5c3-5r3r-rr8q","Warn: Project is vulnerable to: GHSA-rmvr-2pp2-xj38","Warn: Project is vulnerable to: GHSA-xx4v-prfh-6cgc","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-67mh-4wv8-2f99","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22","Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-7m27-7ghc-44w9","Warn: Project is vulnerable to: GHSA-3h52-269p-cp9r","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-353f-5xf4-qw67","Warn: Project is vulnerable to: GHSA-c24v-8rfc-w8vw","Warn: Project is vulnerable to: GHSA-8jhw-289h-jh2g","Warn: Project is vulnerable to: GHSA-64vr-g452-qvp3","Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx","Warn: Project is vulnerable to: GHSA-vg6x-rcgg-rjx6","Warn: Project is vulnerable to: GHSA-x574-m823-4x7w","Warn: Project is vulnerable to: GHSA-4r4m-qw57-chr8","Warn: Project is vulnerable to: GHSA-xcj6-pq6g-qj4x","Warn: Project is vulnerable to: GHSA-356w-63v5-8wf4","Warn: Project is vulnerable to: GHSA-859w-5945-r5v3","Warn: Project is vulnerable to: GHSA-f9xv-q969-pqx4"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T17:03:44.373Z","repository_id":37961683,"created_at":"2025-08-16T17:03:44.373Z","updated_at":"2025-08-16T17:03:44.373Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002069,"owners_count":26083285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"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":["nextjs","vercel"],"created_at":"2024-10-15T01:23:03.263Z","updated_at":"2025-10-11T08:04:35.157Z","avatar_url":"https://github.com/aiji42.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![codecov](https://codecov.io/gh/aiji42/next-with-split/branch/main/graph/badge.svg?token=P126VM3CI1)](https://codecov.io/gh/aiji42/next-with-split)\n[![npm version](https://badge.fury.io/js/next-with-split.svg)](https://badge.fury.io/js/next-with-split)\n\n![How it works 01](https://github.com/aiji42/next-with-split/blob/main/readme/00.png?raw=true)\n\n# :ab: next-with-split\n\n**This is magic!:crystal_ball:**  \nIt enables branch-based split testing (A/B testing) on Vercel and other providers, just like the Netify's [Split Testing](https://docs.netlify.com/site-deploys/split-testing/).\n\nThis plugin lets you divide traffic to your site between different deploys, straight from CDN network. It is not the traditional split testing on a per-component or per-page file basis.   \nYou deploy the main branch (original) and the branch derived from it (challenger) on Vercel and other providers, and use Next.js middleware and cookies to separate two or more environments. Since there is no need to duplicate code, it is easier to manage and prevents the bundle size from increasing.\n\n## Example\n\n[A/B test example](https://next-with-split-aiji42.vercel.app/foo/bar)\n\n## How it works\n\n![How it works 01](https://github.com/aiji42/next-with-split/blob/main/readme/01.png?raw=true)\n\n![How it works 02](https://github.com/aiji42/next-with-split/blob/main/readme/02.png?raw=true)\n\n## Require\n\n- Using Next.js \u003e=13\n\nIf you are using Next.js v12 series, use next-with-split@5.1.0.\n\n## Installation\n\n```\nnpm install --save next-with-split\n```\n\n## Usage\n1\\. Customize `next.config.js` and create `middleware.ts`. (in main branch)\n```js\n// next.config.js\nconst withSplit = require('next-with-split').withSplit({})\n\nmodule.export = withSplit({\n  // write your next.js configuration values.\n})\n```\n\n```js\n// middleware.ts\nexport { middleware } from 'next-with-split'\n```\n\nIf you already have middleware code, please refer to the following.\n```js\n// middleware.ts\nimport { middleware as withSplit } from 'next-with-split'\n\nexport const middleware = (req) =\u003e {\n  const res = withSplit(req)\n  // write your middleware code\n  return res\n}\n```\n\n2\\. Derive a branch from the main branch as challenger. \n- **NOTE:** Challenger branch also needs to have `next.config.js` customized (No. 1).\n\n3\\. Deploy the challenger branch for preview and get the hostname.\n\n4\\. Modify next.config.js in the main branch.\n```js\n// next.config.js\nconst withSplit = require('next-with-split').withSplit({\n  splits: {\n    example1: { // Identification of A/B tests (any)\n      path: '/foo/*', // Paths to perform A/B testing. (regular expression)\n      hosts: {\n        // [branch name]: host name\n        original: 'example.com',\n        'challenger-for-example1': 'challenger-for-example1.vercel.app',\n      },\n      cookie: { // Optional (For Sticky's control)\n        maxAge: 60 * 60 * 12 * 1000 // Number of valid milliseconds for sticky sessions. (default is 1 day)\n      }\n    },\n    // Multiple A/B tests can be run simultaneously.\n    example2: {\n      path: '/bar/*',\n      hosts: {\n        original: 'example.com',\n        'challenger-for-example2': 'challenger-for-example2.vercel.app',\n        // It is possible to distribute access to two or more targets as in A/B/C testing.\n        'challenger2-for-example2': 'challenger2-for-example2.vercel.app',\n      }\n    }\n  }\n})\n\nmodule.export = withSplit({\n  // write your next.js configuration values.\n})\n```\n- If you use a provider other than Vercel, please configure the following manual.  \n**Note: This setting is also required for the Challenger deployments.**\n```js\n// next.config.js\nconst withSplit = require('next-with-split').withSplit({\n  splits: {...},\n  isOriginal: false, // Control it so that it is true on the original deployment (basically the main branch) and false on all other deployments.,\n  hostname: 'challenger.example.com', // Set the hostname in the Challenger deployment. If this is not set, you will not be able to access the assets and images.\n  currentBranch: 'chllenger1', // Optional. Set the value if you use `process.env.NEXT_PUBLIC_IS_TARGET_SPLIT_TESTING`.\n})\n\nmodule.export = withSplit({\n  // write your next.js configuration values.\n})\n```\n\n5\\. Deploy the main branch.\n\n6\\. The network will be automatically split and the content will be served!  \nIt is also sticky, controlled by cookies.\n\n## Features\n- If the deployment is subject to A/B testing, `process.env.NEXT_PUBLIC_IS_TARGET_SPLIT_TESTING` is set to 'true'.\n    - CAUTION: Only if the key set in `hosts` matches the branch name.\n    \n- When Next.js preview mode is turned on, access will automatically be allocated to the original deployment.\n    - Set the `hosts` key to `original`, `master` or `main`.\n\n- You can control the behavior of `withSplit` by forcing it by passing an environment variable at server startup.  \nUse it for verification in your development environment.\n    - `SPLIT_ACTIVE=true yarn dev`: forced active.\n    - `SPLIT_DISABLE=true yarn dev`: forced disable.\n    \n- By default, access to deployments is allocated in equal proportions. If you want to add bias to the access sorting, set `wight`.\n```js\n// next.config.js\nconst withSplit = require('next-with-split').withSplit({\n  splits: {\n    example1: {\n      path: '/foo/*',\n      hosts: {\n        // original : challenger1 : challenger2 = 3(50%) : 2(33%) : 1(16%)\n        original: { host: 'example.com', weight: 3 },\n        challenger1: { host: 'challenger1.vercel.app', weight: 2 },\n        challenger2: 'challenger2.vercel.app', // If `weight` is not specified, the value is 1.\n      }\n    }\n  }\n})\n```\n\n## Impact on Performance\n\nThis library uses middleware to allocate A/B tests. In general, inserting middleware into the route of the content adds some overhead.  \nWe actually deployed it to Vercel and measured the difference between the original and challenger, and the average difference was 70 to 90ms ([#137](https://github.com/aiji42/next-with-split/issues/137#issuecomment-993518576)).  \nThe challenger is rewritten to a different host according to the configuration in the middleware, which causes a round trip.  \nThe original also had an overhead of about 50ms compared to when no A/B testing was done (when no middleware was deployed). In other words, the challenger has a delay of up to 150ms compared to when it is not A/B tested.  \nOnce the user lands on a page, these delays are not a big problem since navigation between pages is resolved quickly by prefetch, but be careful when landing or processing a full page reload. (Google says that TTFB should be less than 200ms.)\n\nTo avoid adding unnecessary latency...\n1. Make sure that the middlewares do not get into routes that are not related to A/B testing.\n    - Use [`confit.matcher`](https://nextjs.org/docs/advanced-features/middleware#matcher) to limit the scope of influence of the middleware to the target path of the A/B test.\n2. The middleware for next-with-split is not needed in challengers, so remove the middlewares. (You do need to configure next.config.js, however.)\n3. While stopping A/B tests, remove the middlewares.\n\n## Contributing\nPlease read [CONTRIBUTING.md](https://github.com/aiji42/next-with-split/blob/main/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE](https://github.com/aiji42/next-with-split/blob/main/LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiji42%2Fnext-with-split","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faiji42%2Fnext-with-split","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiji42%2Fnext-with-split/lists"}