GithubHelp home page GithubHelp logo

pi0 / nuxt-unleash Goto Github PK

View Code? Open in Web Editor NEW

This project forked from conejerock/nuxt-unleash

1.0 1.0 0.0 423 KB

Nuxt.js module to use Unleash toggle feature services

License: MIT License

Shell 1.18% JavaScript 19.70% TypeScript 71.82% Vue 7.30%

nuxt-unleash's Introduction

nuxt-unleash

npm version npm downloads Github Actions CI Codecov License

Nuxt.js module to use Unleash toggle feature services

๐Ÿ“– Release Notes

Features

Use $unleash to access and handle your Unleash feature flags in client side, or context.app.unleash to access Unleash feature flags from server side.

Setup

  1. Add nuxt-unleash dependency to your project
yarn add nuxt-unleash
  1. Add nuxt-unleash to the modules section of nuxt.config.js
export default {
  modules: [
    // Simple usage
    'nuxt-unleash',

    // With options
    ['nuxt-unleash', { /* module options */ }]
  ]
}

โš ๏ธ If you are using Nuxt < v2.9 you have to install the module as a dependency (No --dev or --save-dev flags) and use modules section in nuxt.config.js instead of buildModules.

Using top level options

export default {
  buildModules: [
    'nuxt-unleash'
  ],
  unleash: {
    /* module options */
  }
}

Options

url

  • Type: String
  • Required: true

Unleash API URL

instanceId

  • Type: String
  • Required: true

Unleash API Instance ID

environment

  • Type: String
  • Required: false

Name of the environment your Unleash application runs in. See the example configuration.

config

The module allows some configuration parameters.

If you want to default to the value of a feature that doesn't exist, use:

enabledDefault: true

On the other hand, to set a header as the source of the ip, you can add:

headerIP: 'CF-Connection-IP'

Usage

Client Side

To access the module in side client you just have to call this.$unleash and method you want to use.

<template>
  <h1>{{ value ? 'enabled' : 'disabled' }}</h1>
</template>

<script>
export default {
  mounted() {
    this.value = this.$unleash.isEnabled('new-feature')
  }
}
</script>

Sever Side

To access the module in side server you just have to call ctx.app.unleash and method you want to use.

asyncData(ctx) {
  const value = ctx.app.unleash.isEnabled('new-feature')
  if(value) {
      ctx.redirect('/new-feature-page')
  }
}

Development

  1. Clone this repository
  2. Install dependencies using yarn install or npm install
  3. Start development server using npm run dev

License

MIT License

Copyright (c) Conejerock

nuxt-unleash's People

Contributors

blackerve avatar conejerock avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.