Skip to content

alxspiker/Pi-Network-Developer-Docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

121 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿฅง Pi Developer Handbook

Massive overhaul to this project!

The Complete Resource for Building Pi Network Applications

Pi Network Documentation Examples Hybrid Apps

Build applications that work seamlessly in both Web2 and Web3 environments

๐Ÿ“– View Documentation โ€ข ๐Ÿš€ Get Started โ€ข ๐Ÿ’ป Examples โ€ข ๐Ÿ”„ Migration Guide


๐ŸŒŸ What's New: Hybrid App Architecture

Revolutionary Update! This handbook now includes comprehensive support for hybrid applications that provide seamless experiences across both regular browsers and Pi Browser:

  • โœ… Smart Pi Browser Detection - Automatically detect user environment
  • โœ… Graceful Fallbacks - Clean UI for non-Pi Browser users
  • โœ… No Scary Popups - Better authentication flows
  • โœ… Broader Reach - Support both Web2 and Web3 users
  • โœ… Future-Proof - Ready for Pi Network mainstream adoption

๐Ÿš€ Quick Start

For New Developers

# 1. Clone this repository
git clone https://github.com/alxspiker/Pi-Developer-Handbook.git
cd Pi-Developer-Handbook

# 2. Explore the examples
cd examples/

# 3. Check out the hybrid app guide
# Visit: wiki/Pi-Browser-Detection

For Existing Pi Apps

Need to upgrade your app to hybrid architecture? ๐Ÿ“š Migration Guide - Step-by-step upgrade instructions

๐Ÿ“š Documentation Structure

Core Guides

Guide Description Best For
Pi Browser Detection Build hybrid apps for Web2 & Web3 Essential for all new apps
SDK Reference Complete Pi SDK documentation API integration
Authorization User authentication patterns Login systems
Payments Payment integration guide Monetization

Platform Understanding

๐Ÿ’ป Code Examples

Updated Examples with Hybrid Support

Example Description Technologies
basic-login-and-pay Simple authentication + payments Vanilla JS, HTML
python-login-pay-subscriptions Subscription service with Flask Python, Flask, JavaScript
Pi-Network-SDK-Example Comprehensive SDK showcase HTML, JavaScript

All examples now include:

  • ๐Ÿ” Pi Browser detection
  • ๐ŸŽจ Fallback UI for regular browsers
  • ๐Ÿ‘ค User-initiated authentication
  • ๐Ÿ’ณ Conditional payment flows
  • ๐Ÿ›ก๏ธ Proper error handling

Quick Example - Hybrid Authentication

// Modern hybrid app approach
async function initializeApp() {
  const isPiBrowser = await detectPiBrowser();
  
  if (!isPiBrowser) {
    // Show fallback for regular browsers
    showPiBrowserRequired();
    return;
  }

  // Only show Pi features in Pi Browser
  enablePiFeatures();
}

async function handleLogin() {
  try {
    const auth = await Pi.authenticate(['payments'], onIncompletePaymentFound);
    console.log('โœ… Authentication successful:', auth);
  } catch (error) {
    console.error('โŒ Authentication failed:', error);
  }
}

๐Ÿ—๏ธ Architecture Benefits

Traditional Approach vs Hybrid Approach

Aspect Traditional Hybrid (Recommended)
Browser Support Pi Browser only All browsers with smart fallbacks
User Experience Scary popups in regular browsers Clean, professional experience
Market Reach Pi Network users only Web2 + Web3 audiences
Authentication Auto-login (poor UX) User-initiated (better UX)
Payments Hard failures Graceful degradation

๐Ÿ› ๏ธ Developer Tools

Utility Functions

  • Pi Browser Detection - Smart detection with fallbacks
  • Authentication Helpers - User-initiated login patterns
  • Payment Wrappers - Conditional payment flows
  • Fallback UI Generators - Professional non-Pi Browser experiences

Testing Checklist

  • Works in regular browsers (Chrome, Firefox, Safari)
  • Works in Pi Browser with full functionality
  • No authentication popups in regular browsers
  • Clear messaging for non-Pi Browser users
  • Proper error handling and cleanup

๐Ÿค Contributing

We welcome contributions! Here's how you can help:

  1. Documentation - Improve guides and tutorials
  2. Examples - Add new code samples
  3. Bug Reports - Report issues with existing examples
  4. Feature Requests - Suggest new guides or improvements

๐Ÿ“– Contributing Guidelines - Detailed contribution instructions

๐Ÿ“ž Community & Support

๐Ÿ“„ Resources

Official Pi Network

Developer Resources


๐Ÿš€ Ready to build the future of Pi Network applications?

๐Ÿ“– Start with the Documentation โ€ข ๐Ÿ’ป Explore Examples โ€ข ๐Ÿ”„ Upgrade Existing Apps

Let's build amazing Pi Network applications together!

โšก