createSolvaPay
SolvaPay SDK / server/src / createSolvaPay
Function: createSolvaPay()
createSolvaPay(
config?):SolvaPay
Defined in: packages/server/src/factory.ts:566
Create a SolvaPay instance with paywall protection capabilities.
This factory function creates a SolvaPay instance that can be used to protect API endpoints, functions, and MCP tools with usage limits and
- purchase checks.
Parameters
config?
Optional configuration object
Returns
SolvaPay instance with payable() method and API client access
Example
// Production: Use environment variable (recommended)
const solvaPay = createSolvaPay();
// Production: Pass API key explicitly
const solvaPay = createSolvaPay({
apiKey: process.env.SOLVAPAY_SECRET_KEY
});
// Testing: Use mock client
const solvaPay = createSolvaPay({
apiClient: mockClient
});
// Create payable handlers for your product
const payable = solvaPay.payable({
product: 'prd_myapi',
plan: 'pln_premium'
});
// Protect endpoints with framework-specific adapters
app.post('/tasks', payable.http(createTask)); // Express/Fastify
export const POST = payable.next(createTask); // Next.js App Router
const handler = payable.mcp(createTask); // MCP servers
See
- SolvaPay for the returned instance interface
- CreateSolvaPayConfig for configuration options
Since
1.0.0