|
| 1 | +--- |
| 2 | +name: A/B Testing with A/BBY |
| 3 | +slug: ab-testing-abby |
| 4 | +description: A/BBY is a service for developer focused Feature Flags & A/B Testing. In this template you'll be able to use feature flags and A/B tests at the edge. |
| 5 | +framework: Next.js |
| 6 | +useCase: Edge Middleware |
| 7 | +css: Tailwind |
| 8 | +deployUrl: https://vercel.com/new/clone?repository-url=https://github.com/vercel/examples/tree/main/edge-middleware/ab-testing-abby&env=NEXT_PUBLIC_ABBY_PROJECT_ID&project-name=abby-demo&repository-name=ab-testing-abby |
| 9 | +demoUrl: https://abby-nextjs-example.vercel.app/ |
| 10 | +relatedTemplates: |
| 11 | + - ab-testing-simple |
| 12 | +--- |
| 13 | + |
| 14 | +# A/B Testing with ConfigCat |
| 15 | + |
| 16 | +[A/BBY](https://tryabby.dev) is a service for developer focused Feature Flags & A/B Testing. In this Demo you'll be able to use feature flags and A/B tests at the edge. |
| 17 | + |
| 18 | +By A/B testing directly on the server-side, you'll reduce layout shift from client-loaded experiments and improving your site's performance with smaller JavaScript bundles. |
| 19 | + |
| 20 | +## Demo |
| 21 | + |
| 22 | +https://abby-nextjs-example.vercel.app/ |
| 23 | + |
| 24 | +## How to Use |
| 25 | + |
| 26 | +You can choose from one of the following two methods to use this repository: |
| 27 | + |
| 28 | +### One-Click Deploy |
| 29 | + |
| 30 | +Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme): |
| 31 | + |
| 32 | +[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/examples/tree/main/edge-middleware/ab-testing-abby&env=NEXT_PUBLIC_ABBY_PROJECT_ID&project-name=abby-demo&repository-name=ab-testing-abby) |
| 33 | + |
| 34 | +### Clone and Deploy |
| 35 | + |
| 36 | +Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [pnpm](https://pnpm.io/installation) to bootstrap the example: |
| 37 | + |
| 38 | +```bash |
| 39 | +pnpm create next-app --example https://github.com/vercel/examples/tree/main/edge-middleware/ab-testing-abby ab-testing-abby |
| 40 | +``` |
| 41 | + |
| 42 | +You'll need to have a free [A/BBY](https://tryabby.dev/login) account. Once that's done, copy the `.env.example` file in this directory to `.env.local` (which will be ignored by Git): |
| 43 | + |
| 44 | +```bash |
| 45 | +cp .env.example .env.local |
| 46 | +``` |
| 47 | + |
| 48 | +Then open `.env.local` and set the `NEXT_PUBLIC_ABBY_PROJECT_ID` environment variable to your project's id. Your can copy your project's ID by clicking the Code button on the top right of your dashboard and selecting _Copy Project ID_. |
| 49 | + |
| 50 | +The demo uses needs the following to be set in your A/BBY project: |
| 51 | + |
| 52 | +- 1 Environment called _default_ |
| 53 | +- 2 Feature Flags (_serverFlag_ and _clientFlag_) |
| 54 | +- 2 A/B Tests (_Home_ and _Marketing_) |
| 55 | + |
| 56 | +Next, run Next.js in development mode: |
| 57 | + |
| 58 | +```bash |
| 59 | +pnpm dev |
| 60 | +``` |
| 61 | + |
| 62 | +The `middleware.ts` file is used for the `/marketing` and `home/` routes. The user will see the page for his variant. |
| 63 | + |
| 64 | +The index page ([pages/index.tsx](pages/index.tsx)) also shows how to do AB testing under the same path, in SSR and client-side. |
| 65 | + |
| 66 | +Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=edge-middleware-eap) ([Documentation](https://nextjs.org/docs/deployment)). |
0 commit comments