@build-from-bits/react-helpers
v1.0.0
Published
React hooks and helpers (script loading, previous-value hook, color/URL utilities).
Readme
@build-from-bits/react-helpers
React hooks and helpers: script loading, previous-value tracking, and color/URL utilities.
Install
npm install @build-from-bits/react-helpersHooks
usePrevious(value)— returns the previous value across renders.useExternalScripts({ url })— loads an external script into<head>while mounted.usePaymentGatewayScript()— loads the Razorpay checkout script.
Helpers
goBack()—window.history.back()(no-op on the server).isNativePlatform()—truewhen running inside a Capacitor native shell (reads the runtimewindow.Capacitorglobal).hexToRGB(cssVar)/rgbToHex(rgb)— color conversion helpers.getExtension(path)— lowercased file extension.capitalizeFirstLetter(str).getWhatsAppURL(phone, message)— WhatsApp deep link.COUNTRY_CODE,WHATSAPP— constants.
Usage
import { usePrevious, useExternalScripts, getWhatsAppURL } from '@build-from-bits/react-helpers';
function Component() {
const prev = usePrevious(count);
useExternalScripts({ url: 'https://cdn.example.com/x.js' });
return <a href={getWhatsAppURL('9876543210', 'Hi')}>Chat</a>;
}Publish
npm run build
npm run pack:check
npm run publish:npm
npm run publish:githubLicense
Licensed under the Apache License 2.0.
Copyright 2026 Build From Bits Pvt Ltd.
