
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@myflags/react
Advanced tools
MyFlags - The modern way to manage feature flags in your applications. Ship features faster, control releases with confidence, and deliver better user experiences.
React bindings for MyFlags SDK, providing hooks and components for easy feature flag management in React applications.
npm install @myflags/react @myflags/core
# or
yarn add @myflags/react @myflags/core
# or
pnpm add @myflags/react @myflags/core
import { MyFlagsProvider } from "@myflags/react";
function App() {
return (
<MyFlagsProvider
config={{
apiKey: "your-api-key",
projectId: "your-project-id",
environment: "production",
refreshInterval: 600000, // optional, defaults to 10 minutes
retryCount: 3, // optional, defaults to 3 retries
retryDelay: 1000, // optional, defaults to 1000ms between retries
}}
>
<YourApp />
</MyFlagsProvider>
);
}
import useFlag from "@myflags/react";
function MyComponent() {
// Check if a feature is enabled
const isEnabled = useFlag("feature_key");
// With default value
const isEnabledWithDefault = useFlag("feature_key", false);
if (isEnabled) {
return <div>New feature is enabled!</div>;
}
return <div>Feature is disabled</div>;
}
import { FeatureFlag, FeatureValue } from "@myflags/react";
function MyComponent() {
return (
<div>
<FeatureFlag name="feature_key">
{(enabled) => (enabled ? <NewFeature /> : <OldFeature />)}
</FeatureFlag>
<FeatureValue name="theme_color" defaultValue="blue">
{(color) => <div style={{ color }}>Themed content</div>}
</FeatureValue>
</div>
);
}
By default, MyFlags stores feature flag data in IndexedDB for persistent storage between browser sessions.
You can access all flags with the useFlags hook:
import { useFlags } from '@myflags/react';
function YourComponent() {
const flags = useFlags();
return (
<pre>{JSON.stringify(flags, null, 2)}</pre>
);
}
The provider component that makes feature flags available to all child components.
<MyFlagsProvider config={config}>
<YourApp />
</MyFlagsProvider>
Props:
config: Configuration object for the MyFlags SDK
apiKey: string (required) - Your MyFlags API keyprojectId: string (optional) - Your project IDenvironment: 'production' | 'development' | 'testing' (optional) - Environment to userefreshInterval: number (optional) - Refresh interval in millisecondsretryCount: number (optional) - Number of retries for failed API requests (defaults to 3)retryDelay: number (optional) - Delay between retries in milliseconds (defaults to 1000)Hook to check if a feature is enabled.
const isEnabled = useFlag(name: string, defaultValue: boolean = false): boolean;
Provider Placement
MyFlagsProvider as high as possible in your component treePerformance Optimization
useFlag hook for boolean flagsReact.memoError Handling
Testing
import { MyFlagsProvider } from "@myflags/react";
import useFlag from "@myflags/react";
function App() {
return (
<MyFlagsProvider
config={{
apiKey: "your-api-key",
projectId: "your-project-id",
environment: "production",
retryCount: 3, // optional, defaults to 3 retries
retryDelay: 1000, // optional, defaults to 1000ms between retries
}}
>
<Header />
<MainContent />
<Footer />
</MyFlagsProvider>
);
}
function MainContent() {
const isNewDashboardEnabled = useFlag("new-dashboard");
return (
<main>{isNewDashboardEnabled ? <NewDashboard /> : <OldDashboard />}</main>
);
}
See the Contributing Guide for details on how to contribute to this package.
This package is licensed under the MIT License - see the LICENSE file for details.
FAQs
React bindings for MyFlags feature flag management
We found that @myflags/react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.