Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

samueltuyizere/pi-react

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pi-react

pi-react is a React library for integrating the Pi Network SDK into React projects easily.

Installation

npm install pi-react

Usage

Initialize the SDK

Use the usePiSDK hook to initialize the Pi SDK in your app:

import { usePiSDK } from "pi-react";

const App = () => {
  const isInitialized = usePiSDK(true); // Enable sandbox mode

  return <div>{isInitialized ? "SDK Initialized" : "Loading SDK..."}</div>;
};

Authenticate Users

Use the PiAuth component to authenticate users:

import { PiAuth } from "pi-react";

const App = () => {
  const handleAuthSuccess = (authResult) => {
    console.log("Authenticated user:", authResult.user);
  };

  return <PiAuth onAuthSuccess={handleAuthSuccess} />;
};

Handle Payments

Use the PaymentButton component to handle payments:

import { PaymentButton } from "pi-react";

const App = () => {
  const handleServerApproval = (paymentId) => {
    console.log("Payment ready for approval:", paymentId);
  };

  return (
    <PaymentButton
      amount={3.14}
      memo="Test Payment"
      onReadyForServerApproval={handleServerApproval}
    />
  );
};

About

a React library for integrating the Pi Network SDK into React projects easily.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.