Before writing any code, read the critical rule below.
Use the framework package. Do NOT use
window.Pidirectly.Pi Network provides framework-specific npm/gem packages that wrap the raw
window.Pibrowser SDK. When one of these packages is available for your stack, all auth and payment calls must go through the package’s hooks or helpers — never throughwindow.Pidirectly.
Stack Use this package Correct hook / helper React pi-sdk-reactusePiConnection(),usePiPurchase()Next.js pi-sdk-nextjsScaffolded components + API routes Express pi-sdk-expresscreatePiPaymentRouter()Django pi-sdk-djangoPackage helpers Rails pi-sdk-railsGenerated controller + gem helpers No framework pi-sdk-jsPiSdkBase.connect(),PiSdkBase.createPayment()Only reach for
window.Pi.*directly if you are usingpi-sdk-jsin a vanilla-JS context, or to accesswindow.Pi.Ads(ads), which no wrapper package exposes yet. Never mixwindow.Pi.authenticate()orwindow.Pi.createPayment()with React hooks.
Use these GenAI-specific guides to integrate Pi Network features quickly with helper packages and standard patterns: