> For the complete documentation index, see [llms.txt](https://recuro.gitbook.io/recuro-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://recuro.gitbook.io/recuro-sdk/getting-started/quick-start.md).

# Quick Start

Subscribe to a plan and manage your subscription in under 5 minutes.

## Prerequisites

* A Solana wallet such as Phantom or Solflare
* A React app or a script that can provide an Anchor wallet object
* Devnet SOL for fees while testing
* Devnet USDC if you want to test the full payment flow

If you're using React, you also need `@solana/wallet-adapter-react` so the SDK can read the connected wallet.

## 1. Install the SDK

```bash
yarn add @recuro/sdk
npm install @recuro/sdk
```

## 2. Initialize the SDK

If you're in React, get `wallet` from `useWallet()`. If you're in a script or backend, pass any Anchor-compatible wallet object.

```typescript
import { AnchorProvider } from "@coral-xyz/anchor";
import { SubscriptionSdk } from "@recuro/sdk";
import { Connection, PublicKey, clusterApiUrl } from "@solana/web3.js";

// React example:
// const { wallet } = useWallet();

const connection = new Connection(clusterApiUrl("devnet"));
const provider = new AnchorProvider(connection, wallet, {
  commitment: "confirmed",
});

const sdk = new SubscriptionSdk(provider, { cluster: "devnet" });
```

## 3. Find and Subscribe to a Plan

```typescript
// Fetch available plans from a merchant
const merchantWallet = new PublicKey("merchant_address_here");
const plans = await sdk.fetchMerchantPlans(merchantWallet);

// Subscribe to first available plan
if (plans.length > 0) {
  const plan = plans[0];
  console.log(
    `Subscribing to: ${plan.name} - $${plan.amountUsdc.toNumber() / 1e6} USDC`,
  );

  const { subscriptionPubkey, signature } = await sdk.createSubscription({
    planPubkey: plan.publicKey,
  });

  console.log("✓ Subscribed:", subscriptionPubkey.toBase58());
  console.log("  Tx:", signature);
}
```

## 4. View Your Subscriptions

```typescript
const subscriptions = await sdk.fetchSubscriberSubscriptions(wallet.publicKey);

console.log(`You have ${subscriptions.length} subscription(s)`);

subscriptions.forEach((sub) => {
  const nextPaymentDate = new Date(sub.nextPaymentAt.toNumber() * 1000);
  console.log(`
    Status: ${sub.status}
    Amount: $${sub.amountUsdc.toNumber() / 1e6} USDC
    Next payment: ${nextPaymentDate.toLocaleDateString()}
    Total paid: $${sub.totalPaid.toNumber() / 1e6} USDC
  `);
});
```

## 5. Manage Your Subscription

```typescript
// Pause (temporarily stop payments)
await sdk.pauseSubscription(subscriptionPubkey);
console.log("✓ Subscription paused");

// Resume
await sdk.resumeSubscription(subscriptionPubkey);
console.log("✓ Subscription resumed");

// Cancel (permanently end and revoke delegate)
await sdk.cancelSubscription(subscriptionPubkey);
console.log("✓ Subscription cancelled - delegate revoked");
```

## Trial period note

If the merchant enabled a trial period, the first payment is delayed until the trial ends. After that, the normal billing interval starts.

## What just happened

* You connected to a Recuro plan created by a merchant.
* When you subscribed, you approved a **scoped SPL delegate** limited to the plan amount per cycle.
* A Subscription PDA was created on-chain linking your wallet to the plan.
* The keeper will execute your first payment after any trial period.
* You can pause, resume, or cancel anytime-cancellation immediately revokes the delegate.

## Next steps

* [**How it Works**](/recuro-sdk/getting-started/how-it-works.md) - Understand the architecture
* [**Integration Guide**](/recuro-sdk/getting-started/integration-guide.md) - Full walkthrough with React components
* [**SDK Reference**](/recuro-sdk/subscription-management/create-subscription.md) - Deep dive into each method

***

> 💬 Found an issue or have a question? [Open an issue on GitHub](https://github.com/AlexNaskida/recuro-sdk/issues)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://recuro.gitbook.io/recuro-sdk/getting-started/quick-start.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
