
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
test-it-nuxt
Advanced tools
A powerful and easy-to-use A/B testing module for Nuxt.js applications, powered by Test It.
Install the module using your preferred package manager:
# Using npm
npm install test-it-nuxt
# Using yarn
yarn add test-it-nuxt
# Using pnpm
pnpm add test-it-nuxt
nuxt.config.ts:export default defineNuxtConfig({
modules: ["test-it-nuxt"],
public: {
abTesting: {
projectId: "your-project-id",
},
},
});
Use the useExperiment composable in your Vue component:
<script setup>
import { useExperiment } from "#app";
const experiment = useExperiment("66b035275d5278173af744xx");
experiment.setVariants([
{ id: "66b035275d5278173af744xx", name: "blue", weight: 0.5 },
{ id: "66b035275d5278173af744xx", name: "red", weight: 0.5 },
]);
</script>
Check which variant the user is assigned to:
You can use experiment.isVariant to check if the user is in a specific variant.
It works in both template and script setup.
// script setup
<script setup>
const buttonColor = experiment.isVariant("blue") ? "blue" : "red";
</script>
// template
<template>
<button v-if="experiment.isVariant('blue')" class="bg-blue-500">
Click me
</button>
<button v-else class="bg-red-500">Click me</button>
</template>
Track conversion events using the trackExperimentEvent composable:
<script setup>
function handleClick() {
trackExperimentEvent("66b035275d5278173af744xx");
}
</script>
<template>
<button @click="handleClick">Click me</button>
</template>
useExperiment(experimentId: string)Creates an experiment instance.
setVariants(variants: Variant[]): void - Sets the variants for the experimentisVariant(variantName: string): boolean - Checks if the current variant matches the given namecurrentVariant: Ref<Variant | null> - The current variant for the usertrackExperimentEvent(eventId: string, data?: object)Tracks a custom event for the experiment. Optionally pass data to track.
Configure the module in your nuxt.config.ts:
export default defineNuxtConfig({
// ... other config
abTesting: {
projectId: "your-project-id",
cookieKey: "experiments",
},
});
IMO it's better to manually track page views using the trackExperimentEvent composable. It's not an analytics app, so only track what you need.
If you do have suggestions for improvements, let me know!
FAQs
AB Testing Nuxt
We found that test-it-nuxt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.