ConfigCat SDK for React applications (alpha version)
https://configcat.com
ConfigCat SDK for React provides easy integration for your web application to ConfigCat.
About
Manage features and change your software configuration using ConfigCat feature flags
, without the need to re-deploy code. A 10 minute trainable Dashboard
allows even non-technical team members to manage features directly. Deploy anytime, release when confident.
Target a specific group of users first with new ideas. Supports A/B/n testing and soft launching.
ConfigCat is a hosted feature flag service. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
Getting Started
ConfigCat React SDK builts on our configcat-js SDK (TODO link here). It uses Context API (requires React 16.3 or later) and Hook API (requires React 16.8 or later) to provide a better integration in your React application.
1. Install package:
via NPM package:
npm i configcat-react
3. Import and initialize ConfigCatProvider
In most cases you should wrap your root component with ConfigCatProvider
to access ConfigCat features in child components with Context API.
import React from "react";
import { ConfigCatProvider } from "configcat-react";
function App() {
return (
<ConfigCatProvider
client={/* pass your configcat instance */}
>
{/* your application code */}
</ConfigCatProvider>
);
}
export default App;
4. Get your setting value:
1. Use React hooks - useFeatureFlag, useConfigCatClient
The hooks (useFeatureFlag
) way:
function ButtonComponent() {
const isAwesomeFeatureEnabled = useFeatureFlag(
"isawesomefeatureenabled",
false
);
return (
<button
disabled={!isAwesomeFeatureEnabled}
onClick={() => alert("ConfigCat <3 React")}
>
isAwesomeFeature
</button>
);
}
Need help?
https://configcat.com/support
Contributing
Contributions are welcome. For more info please read the Contribution Guideline.
About ConfigCat