Skip to main content
This guide shows you how to integrate GrowthBook’s JavaScript SDK into your Vue app. We provide examples using both the Composition API and the Options API. While this guide focuses on using GrowthBook in a Vue app, it’s important to note that the underlying functionality is powered by the GrowthBook JavaScript SDK. To explore the full range of methods, capabilities, and customization options, check out the official JavaScript SDK docs.

Installation

Add the @growthbook/growthbook package to your project.

Create a Provider

Use Vue’s app.provide method to make GrowthBook available to your components. In your app’s entry file, usually ./src/main.ts, add the following code:

Inject GrowthBook into a Component

Next, import the gbKey and inject GrowthBook into your component. Below, we use the isOn helper to check if a feature flag is on. See additional helpers in the JS SDK docs.
component.vue

Use the Feature Flag in a Template

Combine Vue’s v-if directive with the showBanner variable to conditionally render content based on the feature flag value.
component.vue

Examples

See examples of using GrowthBook with Vue’s Composition and Options API.