Node.js Subscription Billing with Paylio

One npm install. Full TypeScript support. Check subscriptions and gate features with middleware in any Node.js framework.

Start Free

Integrate in 5 Minutes

# Install

npm install paylio

// Check subscription

const Paylio = require("paylio");

const paylio = new Paylio(process.env.PAYLIO_SECRET_KEY);

const sub = await paylio.getSubscription("user_123");
console.log(sub.status);      // "active"
console.log(sub.plan.name);   // "Pro"
console.log(sub.features);    // { can_export: true, seats: 10 }

// Express middleware

function requirePro(req, res, next) {
  const sub = await paylio.getSubscription(req.user.id);
  if (sub.status === "active" && sub.features.can_export) {
    return next();
  }
  res.status(403).json({ error: "Upgrade to Pro" });
}

app.get("/api/export", requirePro, exportHandler);

Integration Steps

1

Install the SDK

Run npm install paylio to add the Node.js SDK. It includes full TypeScript definitions and has zero runtime dependencies.

2

Initialize the Client

Create a Paylio instance with your secret key. Store the key in an environment variable and initialize once at app startup.

3

Check Subscription

Call paylio.getSubscription(userId) to get the full subscription state including status, plan, billing period, and entitlements.

4

Add Feature-Gating Middleware

Create Express or Fastify middleware that checks entitlements before granting access to premium API routes.

FAQ

How do I add subscription billing in Node.js?

Install the paylio npm package, initialize the client with your secret key, and call paylio.getSubscription(userId). It returns the subscription status, plan details, and entitlements. Use this data to gate features in your API routes.

Does Paylio work with Express, Fastify, and Koa?

Yes. The SDK is a standard Node.js package with no framework dependencies. It works with Express, Fastify, Koa, Hapi, or any Node.js HTTP framework. Import it and call the API from your route handlers or middleware.

Is TypeScript supported?

Yes. The paylio package ships with full TypeScript definitions. All response types including Subscription, Plan, and Entitlement are fully typed. No @types package needed.

How do I check entitlements in Node.js?

The subscription response includes a features object mapping entitlement keys to values. Check sub.features.can_export or sub.features.seats to gate functionality. Create middleware that runs this check before protected routes.

Start Billing with Node.js Today

Free up to 100 subscribers. No credit card required.

Get Your API Key