> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solvapay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript SDK

> SolvaPay SDK is a modern TypeScript SDK for monetizing APIs, AI agents, and MCP (Model Context Protocol) servers with paywall protection and purchase management.

## What is SolvaPay SDK?

SolvaPay SDK helps you monetize APIs, AI apps, and MCP servers with a type-safe API.
You can protect endpoints with paywalls, check purchases, and run checkout flows from one SDK.

## Core capability

Protect routes and tools with one pattern:

```typescript theme={null}
// Express.js
app.post('/tasks', payable.http(createTask))

// Next.js App Router
export const POST = payable.next(createTask)

// MCP Server — register paid tools on the batteries-included factory
const server = createSolvaPayMcpServer({
  solvaPay,
  productRef: 'prd_myapi',
  resourceUri: 'ui://my-app/mcp-app.html',
  htmlPath: './mcp-app.html',
  publicBaseUrl: 'https://my-mcp.example.com',
  additionalTools: ({ registerPayable }) => {
    registerPayable('create_task', {
      schema: { title: z.string() },
      handler: async ({ title }, ctx) => ctx.respond(await createTask(title)),
    })
  },
})
```

## Headless React components

Build beautiful payment flows with headless React components that work with any design system:

```tsx theme={null}
import { PaymentForm, usePurchase } from '@solvapay/react'

function CheckoutPage() {
  const { hasPaidPurchase } = usePurchase()

  return (
    <PaymentForm
      planRef="pln_premium"
      productRef="prd_myapi"
      onSuccess={() => router.push('/dashboard')}
    />
  )
}
```

## Why teams use it

* Single server API for Node and Edge runtimes
* CLI setup with `npx solvapay init`
* Headless React components for checkout flows
* Built-in auth adapters and Next.js helpers

## Packages

| Package                    | Version | Purpose                                                                                                                                                        |
| -------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `@solvapay/core`           | 1.2.0   | Types, schemas, and shared utilities                                                                                                                           |
| `@solvapay/server`         | 2.0.0   | Paywall protection, purchase checks, and webhooks. `@solvapay/server/fetch` ships fetch-native handlers for Edge / Deno / Cloudflare / Supabase Edge Functions |
| `@solvapay/react`          | 1.6.0   | Provider, hooks, checkout, and account components                                                                                                              |
| `@solvapay/react-supabase` | 1.0.10  | Supabase adapter for React                                                                                                                                     |
| `@solvapay/auth`           | 1.1.0   | Auth adapters and server helpers                                                                                                                               |
| `@solvapay/next`           | 1.3.0   | Next.js route helpers                                                                                                                                          |
| `@solvapay/mcp`            | 0.2.8   | MCP server adapter; `@solvapay/mcp/fetch` and `@solvapay/mcp/express` subpaths bridge OAuth by runtime                                                         |
| `solvapay`                 | 1.2.0   | CLI — `npx solvapay init` adds SolvaPay to an existing project                                                                                                 |
| `create-solvapay`          | 0.5.0   | Scaffolder — `npm create solvapay -- --type mcp \| next-auth0`                                                                                                 |

## Next Steps

* [CLI setup](./setup/cli) - Recommended one-command setup
* [Quick start](./setup/quick-start) - Protect your first endpoint
* [Installation](./setup/installation) - Manual setup path
* [Core concepts](./setup/core-concepts) - Products, plans, purchases, and usage
