A comprehensive demo application showcasing the @privy-io/cross-app-provider
SDK utilities for implementing secure cross-app wallet connections and transactions.
This demo app provides interactive examples of all the key utilities in the @privy-io/cross-app-provider
SDK, helping developers understand how to implement cross-app functionality in their own applications.
- Node.js 18+
- npm or yarn
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.env.local
file:# Privy Configuration NEXT_PUBLIC_PRIVY_APP_ID=your_privy_app_id_here
-
Start the development server:
npm run dev
-
Open the demo: Navigate to http://localhost:3000
Demonstrates the complete cross-app connection workflow:
- URL Parameter Parsing: Using
getConnectionRequestFromUrlParams()
to extract connection details - Connection Acceptance: Using
acceptConnection()
to establish secure wallet connections - Connection Rejection: Using
rejectConnection()
to decline connections - Error Handling: Using
handleError()
to communicate failures back to requesting apps - Wallet Creation: Automatic embedded wallet creation for users without wallets
Key SDK Functions:
getConnectionRequestFromUrlParams()
- Parse requester_public_key and requester_origin from URLacceptConnection()
- Accept cross-app connections with encrypted responsesrejectConnection()
- Reject connection requestshandleError()
- Send error responses to requester apps
Shows how to handle transaction requests and message signing:
- Request Verification: Using
getVerifiedTransactionRequest()
to load and decrypt transaction requests - Message Signing: Integration with Privy's
useSignMessage
hook - Success Responses: Using
handleRequestResult()
to send signed results back to requesters - Transaction Rejection: Using
rejectRequest()
to decline transaction requests - Comprehensive Error Handling: Using
handleError()
for various failure scenarios
Key SDK Functions:
getVerifiedTransactionRequest()
- Parse, decrypt, and verify transaction requests from URL parametershandleRequestResult()
- Send encrypted success responses (signatures) back to requesterrejectRequest()
- Send rejection responses for transaction requestshandleError()
- Handle and communicate transaction errors