npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rox-ssr

v6.0.1

Published

Rollout.io ROX JS SDK Client for SSR

Downloads

7,864

Readme

Rollout

CloudBees Feature Management is a secure feature management solution for the enterprise.

Accelerate development and minimize the risk of deploying new code with simple to create feature flags, controlled rollouts, advanced target groups & deployment rules.

Getting Started

Please see the detailed instructions in our docs on how to add CloudBees Feature Management to your project.

Documentation

Getting started guide, use cases, examples and videos can be found at Rollout support site

Rollout JS Server Side Rendering (SSR) SDK 🦆

Rollout JavaScript SSR SDK for web applications that use server side rendering. Define and use simple and advanced feature flags, static and computed custom properties in code. Control your application features via Rollout's dashboard.

Installation

npm i rox-ssr --save

Usage

Basic Usage

Obtain an application key by registering at Rollout.io.

import {RoxString, RoxNumber, Flag, Rox} from 'rox-ssr';

const appSettingsContainer = {
  shouldShowWelcome: new Flag(),
  textColor: new RoxString('red', ['green', 'blue']),
  textSize: new RoxNumber(15, [20, 45])
};

const onRoxReady = () => {
  if (appSettingsContainer.shouldShowWelcome.isEnabled()) {
    const color = appSettingsContainer.textColor.getValue()
    const size = appSettingsContainer.textSize.getValue()
    const div = document
      .createElement('div')
      .textContent('Hello world!')
      .setAttribute('style', `color: ${color}; font-size: ${size}px`)

    const body = document.getElementsByTagName('body')[0]
    body.appendChild(div)
  }
};

Rox.register('settingsNamespace', appSettingsContainer);
Rox.setup('<app key>', {
  configurationFetchedHandler: onRoxReady
});

Hydrate browser-side Rox with flag configuration

In order to ensure the consistency of feature flags between the server and the web clients, the Rollout configuration can easily be sent to the clients.

React example, assuming you already have initialized Rox. Add this to the server-side code, within the <head> tag:

import {Rox} from 'rox-ssr';

// ...
// Your component render() method
render() {
  return (
    <html>
      <head>
        <script type='text/javascript' dangerouslySetInnerHTML={{ __html: `window.rolloutData = ${JSON.stringify(Rox.rolloutData)};` }} />
      <head>
    </html>)
  }

The SDK will automatically use the data inside window.rolloutData instead of fetching the configuration from Rollout's servers.

Configure the SDK with different options

Override the default configuration by prodiving predefined configuration preset for Rox.setup.

For example:

import {Rox} from 'rox-ssr';

/*
- roxOptions.distinctId
- roxOptions.version
- roxOptions.syncComplitionHandler
*/

const roxOptions = {
  distinctId: 'sessionDistinctId',
  version: '1.0',
  configurationFetchedHandler: () => {}
};

Rox.setup('<app key>', roxOptions);

Activating Manual Overrides UI

When running in the browser, you can override flags manually using a built-in UI debug utility that can be activated by invoking Rox.showOverrides().

Running it will display a UI element that allows to explicitly set values of flags. Available UI location of the UI element:

  • 'top left'
  • 'top right'
  • 'bottom left'
  • 'bottom right' (default)

LICENSE

Rollout client JavaScript Server Side Rendering SDK is free-to-use, proprietary software. Please see the full license found under the LICENSE file for more details.

Feedback

Feedback is always welcomed [email protected]