A/B Testing Middleware
Hello everyone,
I'm wanting to do some A/B Testing on Vercel. The guide is for NextJS (https://vercel.com/blog/ab-testing-with-nextjs-and-vercel#experimenting-at-the-edge).
So I'm looking to convert this into Nuxt, the only thing I can't seem to find any information on is how to set a cookie in a Nuxt Middleware. I've attempted to use
I'm wanting to do some A/B Testing on Vercel. The guide is for NextJS (https://vercel.com/blog/ab-testing-with-nextjs-and-vercel#experimenting-at-the-edge).
So I'm looking to convert this into Nuxt, the only thing I can't seem to find any information on is how to set a cookie in a Nuxt Middleware. I've attempted to use
useCookie().Solution
Okay so I've found a solution:
Then
I'm unsure whether this is the best solution, but it seems to be working and SSR friendly in my tests.
/middleware/ab-test.global.tsThen
composables/useVariant.tsI'm unsure whether this is the best solution, but it seems to be working and SSR friendly in my tests.