
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
use-feature-flags
Advanced tools
/!\ COMING SOON !!! You need to use the Feature flags API to use this hook.
npm i use-feature-flags
By default, if a flag cannot be fetched, it will be false.
The Feature Flag API uses the User-Agent header from the request to determine if the user has access to the feature.
import { FlagsProvider, useFlags } from 'use-feature-flags'
function App() {
return <FlagsProvider
config={{
apiUrl: 'your-self-hosted-api-url',
apiServiceId: 'the-service-id',
apiAuthorization: 'the-authorization-key-you-defined-in-the-api',
debug: true // optional, default: false
}}
>
<MyComponent/>
</FlagsProvider>
}
function MyComponent() {
const { isFlagOn, flags, getFlag } = useFlags()
/**
* Two usages :
* - with getFlag(key) => returns the flag object with the value and the enabled status
* - with isFlagOn(key) => returns the enabled status
*/
return <div>
{isFlagOn('my-welcome-message') && <p>{getFlag('my-welcome-message').value}</p>}
{isFlagOn('my-flag-key') ? <p>Hello world !</p> : <p>This feature is off</p>}
</div>
}
// FlagsProvider
interface UseFlagsParams {
config: {
apiUrl: string
apiServiceId: string
apiAuthorization: string,
debug?: boolean
}
}
// useFlags()
interface UseFlagsHook {
// List all flags from the specified services
flags: Flag[]
// Return a specified flag
getFlag: (key: string) => Flag | undefined
// Return the enabled status of a specified flag
isFlagOn: (key: string) => boolean
}
interface Flag {
key: string
enabled: boolean
value: string
}
FAQs
React hooks to fetch flags from Feature Flags API
We found that use-feature-flags 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

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.