1.10.17 • Public • Published

    Izanami react client

    React client

    react-izanami is a simple set of React components to leverage the power of Izanami feature flipping and experiments.

    In order to use the client you need to proxify Izanami to avoid leaking the credentials to the client side.

    Install the client

    npm install react-izanami


    import {IzanamiProvider, Feature, Enabled, Disabled, Experiment, Variant, Api as IzanamiApi} from 'izanami';

    Izanami provider

    You can wrap your application in the izanami provider and let izanami fetch data from the proxy you have exposed:

    <IzanamiProvider fetchFrom="/api/izanami">
        {/* your app */}    

    You can pass fallbacks in the case of the server is not up:

    <IzanamiProvider fetchFrom="/api/izanami" featuresFallback={{my: {feature: {active: true}}}} experimentsFallback={{my:{experiment:{variant: 'B'}}}} >
    {/* ... */}    

    You can also pass features and experiments as props if you don't want the provider to fetch datas:

    <IzanamiProvider features={{my: {feature: {active: true}}}} experiments={{my:{experiment:{variant: 'B'}}}} >
    {/* ... */}

    You can trigger manual reload using the Api class. For example during router transition :

    componentWillReceiveProps(nextProps) {
        // will be true
        const locationChanged = nextProps.location !== this.props.location;
        if (locationChanged) {
          //Reload izanami data on route change

    Feature flipping

    Once you the provider configured, you can switch code depending on a feature :

    <Feature path="izanami.example.deleteAll">
        <div>Fetching izanami features configuration...</div>
          <td><button type="button"  className="btn btn-sm btn-default" onClick={this.deleteAll}>Delete done items</button></td>

    Experiments (A/B testing)

    Once you the provider configured, you can displayed a specific variant for an experiment :

    { =>
        <tr key={`td-${}`}>
          <td><Link to={`/todos/${}`} >{}</Link></td>
            <Experiment path={"izanami:example:button"} notifyDisplay="/api/izanami/experiments/displayed" >
              <Variant id={"A"}>
                <Link to={`/todos/${}`} onClick={this.onTodosClick} className="btn btn-sm btn-default"><i className="fas fa-eye" aria-hidden="true" /></Link>
                <button className="btn btn-sm btn-default" onClick={this.removeTodoList(}><i className="glyphicon glyphicon-trash" /></button>
              <Variant id={"B"}>
                <Link to={`/todos/${}`} onClick={this.onTodosClick} className="btn btn-sm btn-primary"><i className="glyphicon glyphicon-pencil" /></Link>
                <button className="btn btn-sm btn-primary" onClick={this.removeTodoList(}><i className="glyphicon glyphicon-trash" /></button>

    If specified, the notifyDisplay field will call the registered url to notify Izanami that the current variant is displayed.

    You have to call yourself Izanami when a variant won because the react client can't decide this for you :).

    In this example, the variant won if the client click on the button. For that we will do an http POST on /api/izanami/experiments/won when the client click on the link using this function :

    export function notifyWon(key) {
      return fetch(`/api/izanami/experiments/won?experiment=${key}`, {
        method: 'POST',
        credentials: 'include',
        headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json'

    and then when the client click on the link:

    onTodosClick = () => {




    npm i react-izanami

    DownloadsWeekly Downloads






    Unpacked Size

    77 kB

    Total Files


    Last publish


    • adelegue
    • pierrebruninmaif
    • maifpfs