Agent-readable docs index: /llms.txt. Full docs in one file: /llms-full.txt. Download /docs.zip to grep all markdown files locally.

Your first Solana subscriber in four steps

This page takes an empty project to one paying subscriber. It uses the React widget for the wallet part; without it, see subscriptions.create in the @mesub/node README.
  1. Publish a plan
    In the dashboard, open Plans and create one: a name, a price, a token, a period, and the wallet that receives the money. Your wallet signs its creation. An end date is optional.
    Mesub derives the plan's slug from its name: a plan named Pro gets pro. The slug is how your code names the plan everywhere below. You can read it in the plan's Implement tab, where the code on this page is already filled in with it.
  2. Give your server the API key
    In the dashboard, open Developers and create the project's API key. It starts with SUB_ and is shown once: more on the key. Put it in your server's environment:
    MESUB_API_KEY=SUB_...
    Then install the SDK with your package manager:
    npm install @mesub/node
    pnpm add @mesub/node, yarn add @mesub/node and bun add @mesub/node work the same. It goes in dependencies: your server needs it in production.
  3. Mount the routes and gate a route
    Two things on your server. The routes are what the widget calls to subscribe and manage. The gate is the question you ask before serving anything paid. Both need to know who is asking, and that comes from your own login.
    import { Mesub } from '@mesub/node'; import { mesubRoutes } from '@mesub/node/express'; const mesub = new Mesub(); // reads MESUB_API_KEY // What the widget calls. Mount it after your own login. app.use( '/api/mesub', yourLogin, mesubRoutes({ customer: (req) => req.user ? { external_id: req.user.id } : null, }), ); // A paid route. app.get('/api/analytics', yourLogin, async (req, res) => { if (!(await mesub.hasAccess({ external_id: req.user.id }, 'pro'))) { res.status(402).json({ error: 'The Pro plan is needed.' }); return; } res.json(buildAnalytics(req.user)); });
    customer must come from a session you verified, never from what the browser sends. When it returns null, the routes answer 401. The Next.js and NestJS examples use the SDK's guards, which answer 401 and 402 themselves; Express has one too, requirePlan.
  4. Put the button on a page
    npm install @mesub/react
    It needs react and react-dom 18 or later. @mesub/react 0.1.x works with the routes of @mesub/node 0.1.x: keep the two at the same minor.
    Wrap your app once, pointing at where you mounted the routes:
    import { MesubProvider } from '@mesub/react'; import '@mesub/react/styles.css'; export function App({ children }) { return <MesubProvider endpoint="/api/mesub">{children}</MesubProvider>; }
    The wallet signs for devnet by default. For plans on mainnet, add chain="solana:mainnet".
    Then place the button, with the plan's slug:
    import { SubscribeButton } from '@mesub/react'; <SubscribeButton plan="pro">Subscribe to Pro</SubscribeButton>;

Try it

Sign in to your own site and click the button. The window shows the plan, asks for a wallet, then for two approvals: the terms, then the first payment. Once it lands, /api/analytics answers for that customer.
The subscription appears in the dashboard under Subscriptions, with its first payment under Collection. From here Mesub charges it every period without anything more from you.
Next: check access in detail, and webhooks to be told when a subscription renews, misses a payment or ends.