A lightweight React hook to detect Pi Browser environment for hybrid apps.
npm install pi-network-browser-detectbash
npm install pi-network-browser-detect
`
π Why Use This?
Many Pi apps are going hybrid β offering limited features in Web2 browsers and full functionality inside the Pi Browser (Web3 auth, payments, etc.).
This hook lets you:
β
Detect the Pi Browser environment without triggering popups
π Avoid premature Pi.authenticate() calls
π§© Conditionally render features based on browser
π² Offer QR code links or fallback UI for standard browsers
π Usage
`jsx
import useIsPiBrowser from 'pi-network-browser-detect';
const PiOnlyFeature = () => {
const isInPiBrowser = useIsPiBrowser();
if (isInPiBrowser === null) return null; // Still detecting
if (isInPiBrowser === false) {
return (
);
}
return (
Welcome Pi user! You have full access.
);
};
``