Welcome to SolvaPay SDK
SolvaPay SDK is a modern TypeScript SDK for monetizing APIs, AI agents, and MCP (Model Context Protocol) servers with paywall protection and subscription management. It provides a unified API that works across multiple frameworks and runtimes.
What is SolvaPay SDK?β
SolvaPay SDK helps you monetize your APIs, AI agents, and MCP servers with minimal setup. Add paywall protection to your endpoints, manage subscriptions, and process paymentsβall with a simple, type-safe API.
Key Featuresβ
π‘οΈ One-Line Paywall Protectionβ
Protect your API endpoints, functions, and MCP tools with a single line of code:
// Express.js
app.post('/tasks', payable.http(createTask));
// Next.js App Router
export const POST = payable.next(createTask);
// MCP Server
const handler = payable.mcp(createTask);
π³ Headless React Componentsβ
Build beautiful payment flows with headless React components that work with any design system:
import { PaymentForm, useSubscription } from '@solvapay/react';
function CheckoutPage() {
const { hasPaidSubscription } = useSubscription();
return (
<PaymentForm
planRef="pln_premium"
agentRef="agt_myapi"
onSuccess={() => router.push('/dashboard')}
/>
);
}
π Works Out of the Boxβ
- Stub mode - Test without an API key
- Edge runtime support - Deploy globally with low latency
- Automatic runtime detection - Works in Node.js and Edge environments
- Type-safe - Full TypeScript support with comprehensive types
π Secure by Defaultβ
- API keys never exposed to the browser
- Payment flows initiated by backend API routes only
- Webhook signature verification included
- Automatic runtime detection prevents environment mismatches
Quick Startβ
Try an Example (No API Key Required)β
# Clone and setup
git clone https://github.com/solvapay/solvapay-sdk
cd solvapay-sdk
pnpm install && pnpm build
# Run Express example with stub mode
cd examples/express-basic
pnpm dev
The Express example runs in stub mode by default - perfect for testing without an API key!
Install in Your Projectβ
# For server-side paywall protection
npm install @solvapay/server
# For client-side payment flows
npm install @solvapay/react
# For Supabase authentication (optional)
npm install @solvapay/react-supabase @supabase/supabase-js
# For Next.js integration
npm install @solvapay/next
# For authentication adapters
npm install @solvapay/auth
Use Casesβ
API Monetizationβ
Protect your REST or GraphQL APIs with usage limits and subscription checks:
const solvaPay = createSolvaPay();
const payable = solvaPay.payable({
agent: 'agt_myapi',
plan: 'pln_premium'
});
// Protect any endpoint
app.post('/api/generate', payable.http(async (req) => {
// Your business logic here
return { result: 'generated content' };
}));
AI Agentsβ
Monetize AI agent interactions with pay-per-use or subscription models:
// Protect agent endpoints
app.post('/agent/chat', payable.http(async (req) => {
const response = await aiAgent.chat(req.body.message);
return { response };
}));
MCP Serversβ
Protect MCP tools with paywall protection:
import { createSolvaPay } from '@solvapay/server';
const solvaPay = createSolvaPay();
const payable = solvaPay.payable({
agent: 'agt_mcptools',
plan: 'pln_pro'
});
// Protect MCP tools
const handler = payable.mcp(async (args) => {
// Tool implementation
return { result: 'tool output' };
});
Architecture Overviewβ
SolvaPay SDK is organized as a monorepo with 6 published packages:
@solvapay/core- Types, schemas, and shared utilities@solvapay/server- Universal server SDK (Node + Edge runtime)@solvapay/react- Headless payment components and hooks@solvapay/react-supabase- Supabase auth adapter for React Provider@solvapay/auth- Authentication adapters and utilities@solvapay/next- Next.js-specific utilities and helpers
How It Worksβ
- Agent & Plan Setup: Define your agent (API/service) and plans (subscription tiers) in the SolvaPay dashboard
- Protection: Use
payable()to wrap your business logic with paywall protection - Customer Management: Customers are automatically created and synced with your authentication system
- Payment Processing: Integrate Stripe for payment processing (handled by SolvaPay backend)
- Usage Tracking: Track usage and enforce limits automatically
Request Flowβ
Client Request
β
Paywall Check (via payable adapter)
β
Check Subscription Status
β
Has Subscription? β Yes β Execute Business Logic
β No
Check Usage Limits
β
Within Limits? β Yes β Execute Business Logic
β No
Return Paywall Error (with checkout URL)
Next Stepsβ
- Installation Guide - Set up SolvaPay SDK in your project
- Quick Start - Get up and running in 5 minutes
- Core Concepts - Understand agents, plans, and the paywall flow
- Architecture Guide - Detailed technical architecture and package design
Documentationβ
- Framework Guides - Express, Next.js, React, and MCP integration guides
- API Reference - Complete API documentation for all packages
- Examples - Working examples and demos
- Advanced Topics - Custom authentication, error handling, testing, and more
Supportβ
- GitHub Issues: https://github.com/solvapay/solvapay-sdk/issues
- Email: support@solvapay.com
Ready to get started? Check out the Installation Guide or jump straight to the Quick Start!