Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@unleash/proxy-client-react

Package Overview
Dependencies
Maintainers
6
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unleash/proxy-client-react

React interface for working with unleash

  • 4.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
121K
decreased by-6.62%
Maintainers
6
Weekly downloads
 
Created

What is @unleash/proxy-client-react?

@unleash/proxy-client-react is a React client for the Unleash feature management system. It allows developers to easily integrate feature toggles into their React applications, enabling dynamic feature management and experimentation.

What are @unleash/proxy-client-react's main functionalities?

Initialize Unleash Client

This code initializes the Unleash client with the necessary configuration, including the URL of the Unleash API, the client key, and the application name. The `start` method is called to begin fetching feature toggles.

import { UnleashClient } from '@unleash/proxy-client-react';

const client = new UnleashClient({
  url: 'https://app.unleash-hosted.com/demo/api/',
  clientKey: 'proxy-client-key',
  appName: 'my-react-app'
});

client.start();

Use Feature Toggles in Components

This code demonstrates how to use the `useFlag` hook to check the status of a feature toggle within a React component. Depending on whether the feature toggle is enabled or disabled, different content is rendered.

import { useFlag } from '@unleash/proxy-client-react';

const MyComponent = () => {
  const isEnabled = useFlag('my-feature-toggle');

  return (
    <div>
      {isEnabled ? <p>Feature is enabled</p> : <p>Feature is disabled</p>}
    </div>
  );
};

Custom Context Provider

This code shows how to wrap your application with the `UnleashProvider` to provide the Unleash client configuration context to all components within the application. This makes it easier to use feature toggles throughout the app.

import { UnleashProvider } from '@unleash/proxy-client-react';

const App = () => (
  <UnleashProvider
    config={{
      url: 'https://app.unleash-hosted.com/demo/api/',
      clientKey: 'proxy-client-key',
      appName: 'my-react-app'
    }}
  >
    <MyComponent />
  </UnleashProvider>
);

Other packages similar to @unleash/proxy-client-react

Keywords

FAQs

Package last updated on 31 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc