> ## Documentation Index
> Fetch the complete documentation index at: https://x402-stellar.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# @stellar-x402/fastify

> Fastify plugin for HTTP 402 paywalls on Stellar

## Installation

```bash theme={null}
pnpm add @stellar-x402/core @stellar-x402/fastify
```

## Plugin Registration

```typescript theme={null}
import Fastify from 'fastify';
import { fastifyX402 } from '@stellar-x402/fastify';

const fastify = Fastify();

await fastify.register(fastifyX402, {
  price: '0.02',
  asset: 'CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC',
  recipient: 'GCALKSGAZRJLSUEJT3M5W6LN4R7XQOLIRCOS6ZA6EDZVTZDBIIPPFKJ6',
  network: 'stellar:testnet',
  paths: ['/api/v1/premium'],
});

fastify.get('/api/v1/premium', async (req) => {
  return {
    payer: req.x402Payment?.payer,
    status: 'access_granted',
  };
});

await fastify.listen({ port: 3000 });
```

## Route Filtering with `paths`

When the `paths` array is provided, the plugin intercepts only routes that match the specified prefixes. Unmatched routes pass through without paywall checks.
