Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
What is this? Feature flags for ants? Well yes! But also Tiny Flags is simple way to add client-side feature flags that can be updated at runtime.
Well, yes! Antiny 🐜 looks super happy with it. But also it is a simple way to add client-side feature flags that can be updated at runtime using a companion browser extension.
Let PMs, designers, fellow developers or even clients try your awesome new features without worrying about waiting for the whole thing to be finished or blocking a release.
Tiny Flags is a great option when you don't want to pay for a third-party provider. Every user of your application can update the flags' status without the need of re-deploying, allowing them to test in a real environment.
This project also provides full TypeScript support when using the useFlags
hook.
Want to see it in action? Check out the demo.
Also, you can check this CodeSandbox to play with the code.
npm i tiny-flags
First, you'll need a configuration:
// tiny-flags.ts
import { createTinyFlags } from 'tiny-flags';
const flags = {
newFeature: {
label: 'New Feature',
value: false, // value is not required
},
anotherFlag: {
label: 'This is another feature enabled by default',
value: true,
},
};
export const { FlagsProvider, useFlags } = createTinyFlags(flags);
Then you can wrap your application with FlagsProvider.
import ReactDOM from 'react-dom/client';
import App from './App';
import { FlagsProvider } from './tiny-flags';
ReactDOM.render(
<React.StrictMode>
<FlagsProvider><App /></FlagsProvider>
</React.StrictMode>,
document.getElementById('root')
)
Import useFlags
in your components to check your flag's status.
// component.ts
import { useFlags } from './tiny-flags';
const App = () => {
const flags = useFlags();
return (
<div>
This will show if
{ flags.newFeature && <div>Ta-da! 🎉</div> }
</div>
);
};
export default App;
You can also use the FlagsWrapper
component to wrap your components and check the flag's status.
The FlagsWrapper
component receives a condition
prop that can be a string, an array of strings or a function.
true
.// component.ts
import { FlagsWrapper } from './tiny-flags';
const Component = () => {
return (
<FlagsWrapper condition="newFeature">
<div>Ta-da! 🎉</div>
</FlagsWrapper>
);
};
export default Component;
Make sure to import
FlagsProvider
,useFlags
andFlagsWrapper
from thetiny-flags
configuration file and not thetiny-flags
package.
This library establishes a two-way communication with the Tiny Flags Extension so you can see the available flags and also toggle their state.
FAQs
What is this? Feature flags for ants? Well yes! But also Tiny Flags is simple way to add client-side feature flags that can be updated at runtime.
The npm package tiny-flags receives a total of 653 weekly downloads. As such, tiny-flags popularity was classified as not popular.
We found that tiny-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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.