
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.
react-kofi-headless
Advanced tools
A headless React wrapper for Ko-fi's overlay widget, allowing for 100% custom UI triggers.
A headless React wrapper for the Ko-fi overlay widget. Trigger the native Ko-fi donation popup from any custom React component — buttons, links, cards, menus — with full control over positioning.
Ko-fi only provides a fixed, non-customizable button. This library removes that limitation.
window checks for Next.js and Remix compatibility1. Install the package
npm install react-kofi-headless
# or
yarn add react-kofi-headless
2. Wrap your custom component:
import { KofiOverlay } from 'react-kofi-headless';
const DonateButton = () => (
<KofiOverlay kofiId="yourname">
{(open) => (
<button
onClick={open}
className="bg-amber-400 p-4 rounded-xl font-bold hover:scale-105 transition-transform"
>
Support the Project
</button>
)}
</KofiOverlay>
);
3. Use the hook (Optional): For more complex scenarios, like triggering the overlay from a navbar or a keyboard shortcut.
import { useKofi } from 'react-kofi-headless';
const { open } = useKofi('yourname');
<KofiOverlay />
| Prop | Type | Description |
|---|---|---|
| kofiId | string | Required. Your unique Ko-fi username/ID. |
| options | KofiOptions | Optional. Configure colors and text for the native popup. |
| position | PositionOptions | Optional. Configure popup positioning. Default is Ko-fi's behavior. |
| children | function | Required. Receives open and optional bind helpers. |
Positioning is best-effort and depends on Ko-fi's internal DOM/classes. If the popup elements are not found, the library logs a warning and falls back gracefully.
PositionOptions
type PositionMode = 'kofi-default' | 'fixed' | 'anchor';
type FixedPlacement = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center';
type Placement =
| 'bottom-start' | 'bottom' | 'bottom-end'
| 'top-start' | 'top' | 'top-end'
| 'left' | 'left-start' | 'left-end'
| 'right' | 'right-start' | 'right-end'
| 'center';
type PositionOptions = {
mode?: PositionMode;
placement?: Placement | FixedPlacement;
offset?: number;
margin?: number;
flip?: boolean;
clamp?: boolean;
strategy?: 'fixed';
zIndex?: number;
};
Anchored usage (component)
<KofiOverlay
kofiId="yourname"
position={{ mode: 'anchor', placement: 'top-end', offset: 12 }}
>
{(open, bind) => (
<button ref={bind?.ref} onClick={open}>
Donate
</button>
)}
</KofiOverlay>
Anchored usage (hook)
const { open } = useKofi('yourname', {
position: { mode: 'anchor', placement: 'right', offset: 8 },
});
<button onClick={open}>Donate</button>
Open helpers
open(event); // anchors to event.currentTarget
open({ anchorEl }); // anchors to a provided element
This repository includes a pre-configured example app built with Vite and Tailwind CSS. It demonstrates how to trigger the Ko-fi overlay from:
useKofi hook.To run the example locally:
npm run build to compile the library.cd examplenpm installnpm run devYou can also check out the Live Demo to see the library in action.
To play with the code or run the example playground:
git clone https://github.com/areezvisram/react-kofi-headless.gitcd react-kofi-headlessnpm installnpm run buildcd example && npm run devThis project is licensed under the MIT License.
Built to scratch my own itch. I hope it helps you too! If it does, and you want to support me, I would be very grateful (or just star the repo!) :)
FAQs
A headless React wrapper for Ko-fi's overlay widget, allowing for 100% custom UI triggers.
We found that react-kofi-headless 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
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.