
Research
SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.
feature-flip
Advanced tools
Flexible React & React Native feature flagging/flipping/toggling for simple use cases
Flexible React & React Native feature flagging/flipping/toggling for simple use cases
This package facilitates a feature flag-driven workflow within React and React Native applications. It is intended for simple use cases where a local or remote configuration object is used. If you have more complex requirements such as incremental roll-outs please take a look at services such as LaunchDarkly or Unleash.
Install the package locally within you project folder with your package manager:
With npm:
npm install feature-flip
With yarn:
yarn add feature-flip
With pnpm:
pnpm add feature-flip
import {
FeatureFlipsProvider,
FeatureFlip,
withFeatureFlip,
useFeatureFlip
} from "feature-flip";
const features = {
blog: {
header: true,
content: {
intro: "no"
},
footer: false
}
};
const Header = () => {
const isEnabled = useFeatureFlip("blog.header");
return isEnabled ? <header>Header</header> : null;
};
const Intro = withFeatureFlip("content.intro")(() => <p>Intro</p>);
export default function App() {
return (
<FeatureFlipsProvider value={features}>
<div>
<Header />
<main>
<Intro />
<p>This is the content</p>
<FeatureFlip name="missing-flag">
<p>Will not show</p>
</FeatureFlip>
</main>
<FeatureFlip
name="blog.footer"
fallback={<footer>Fallback footer</footer>}
>
<footer>Footer</footer>
</FeatureFlip>
</div>
</FeatureFlipsProvider>
);
}
By providing your own onParseValue configuration option you can handle special cases such as enable/disabling a flag based on a semantic version.
First create your custom handler:
import semver from "semver";
import { defaultValueParser } from "feature-flip";
export const parseSemverValue = (value) => {
if (semver.valid(value)) return semver.satisfies(value);
// If it isn't a valid semver value, handle as normal
return defaultValueParser(value);
};
Now override the config option for your FeatureFlipsProvider:
import {parseSemverValue} from "./parse-semver-value"
const features = {
// ...
}
const App = () => <FeatureFlipsProvider value={features} config={{
onParseValue: parseSemverValue
}}>
<Component />
</FeatureFlipsProvider>
For all configuration options, please see the API docs.
Got an idea for a new feature? Found a bug? Contributions are welcome! Please open up an issue or make a pull request.
FAQs
Flexible React & React Native feature flagging/flipping/toggling for simple use cases
The npm package feature-flip receives a total of 1 weekly downloads. As such, feature-flip popularity was classified as not popular.
We found that feature-flip demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Research
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.