Skip to main content

GenAI Support

Before writing any code, read the critical rule below.

Use the framework package. Do NOT use window.Pi directly.

Pi Network provides framework-specific npm/gem packages that wrap the raw window.Pi browser 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 through window.Pi directly.

StackUse this packageCorrect hook / helper
Reactpi-sdk-reactusePiConnection(), usePiPurchase()
Next.jspi-sdk-nextjsScaffolded components + API routes
Expresspi-sdk-expresscreatePiPaymentRouter()
Djangopi-sdk-djangoPackage helpers
Railspi-sdk-railsGenerated controller + gem helpers
No frameworkpi-sdk-jsPiSdkBase.connect(), PiSdkBase.createPayment()

Only reach for window.Pi.* directly if you are using pi-sdk-js in a vanilla-JS context, or to access window.Pi.Ads (ads), which no wrapper package exposes yet. Never mix window.Pi.authenticate() or window.Pi.createPayment() with React hooks.

Use these GenAI-specific guides to integrate Pi Network features quickly with helper packages and standard patterns: