0.0.5 • Published 1 year ago
nuxt-growthbook v0.0.5
Nuxt GrowthBook
Nuxt GrowthBook integration module.
Quick Setup
- Add
nuxt-growthbookdependency to your project
# Using pnpm
pnpm add -D nuxt-growthbook
# Using yarn
yarn add --dev nuxt-growthbook
# Using npm
npm install --save-dev nuxt-growthbook- Add
nuxt-growthbookto themodulessection ofnuxt.config.ts
export default defineNuxtConfig({
modules: ['nuxt-growthbook']
})- Set client key in
nuxt.config.tsor.envfile
export default defineNuxtConfig({
modules: ['nuxt-growthbook'],
growthbook: {
clientKey: 'YOUR_CLIENT_KEY'
}
})GROWTHBOOK_CLIENT_KEY=YOUR_CLIENT_KEY- You can now use GrowthBook in your Nuxt app ✨
<script setup>
const gb = useGrowthbook();
const bannerEnabled = gb.isOn("banner_enabled");
</script>- Optional: If you want to enable caching for GrowthBook API calls, use the
routeRulesoption in yournuxt.config.tsfile.
export default defineNuxtConfig({
routeRules: {
"/_growthbook/features": { swr: 60 },
},
})Development
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release