Skip to content

anyhive/anyhive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anyhive

You focus on building your product - From Hello World to IPO. We handle payments, billing, and compliance.

Anyhive is an open-source, developer-first Merchant of Record (MoR) and billing layer. With Anyhive, you can build your own checkout and customer portals with hosted UI or embeddable components within minutes.

Open-source billing — pricing, metering, and compliance made simple.

  • Server‑first access control: RSC/SSR‑friendly paywall with one‑line gating (paywall().render) or explicit fetchIfAllowed.
  • Metered billing for tools & AI: quotas, rate limits, overage prompts, and guided upgrades.
  • Compliance from day one: Tax/VAT/GST/JCT ready, with region‑specific modules on the roadmap.
  • Open, portable, and programmable: Your data, your PSPs, your rules.

What is Anyhive?

Anyhive is open-source Merchant of Record (MoR) with payments, subscriptions, and compliance. 100% open-source, 100% portable, 100% programmable.

It includes:

  • A React SDK for embedding pricing tables, checkout, and customer portals.
  • A Next.js hosted checkout page and customer portal.
  • A CLI for installing and managing your pricing plans, subscriptions, and configuration.
  • A comprehensive documentation and examples.
  • An Admin dashboard for managing your pricing plans, subscriptions, and configuration.

With the admin dashboard, you can manage:

  • 📊 Subscriptions & usage-based pricing
  • ✅ Global tax, fraud, and compliance
  • 🔑 Entitlement management & content delivery
  • 🖥️ Embeddable checkout and customer portals

With one SDK + API + CLI + starter templates, developers can own your cross-border payments infra, e.g. collect payments, tax compliance and payouts in minutes, not weeks — without vendor lock-in.

🌏 Roadmap

We ship fast and iterate quickly.

V0.0.1: This week, we will focus on the following:

  • The first release of Anyhive with a sandbox environment with API for pricing plans.
  • The first release of useAnyhive hook for React.
  • The first release of Anyhive CLI.
  • 2 demo examples go live: usage meter and paywalled content.

V0.0.2: Next week, we will focus on the following:

  • Hosted checkout page and customer portal.

Near-term

  • Paywall SDK for content sites: RSC/SSR-first with minimal code changes (fetchIfAllowed, paywall().render).
  • Metered billing for tools/AI: quotas, rate limits, overage prompts, upgrade flows.
  • Default modern UI themes (Minimal, Neobrutal) with data-attributes/class hooks for customization.
  • Frictionless developer onboarding: polished Next.js/React Router examples, quickstart CLI.
  • By default, Anyhive will use Stripe as the default PSP since it is the most widely used and supported PSP.

Mid-term

  • Usage tracking & event pipeline: metering signals, quota policies, billing reconciliation.
  • Pricing & plan tooling: Pricing Table, upgrade/downgrade/grace workflows.
  • Extensibility plugins: LLM API routing, usage analytics, A/B testing, dynamic pricing.
  • PSP baseline integrations: Stripe/PayPal first, then regional providers (PayPay, LINE Pay, Momo…).

Long-term

  • PSP-agnostic payment layer: avoid vendor lock-in, abstract capability/risk switching across PSPs.
  • Tax & compliance: VAT/GST/JCT modules and filing workflows.
  • Globalization: localized payment experiences, regulatory compliance, regionalized billing/tax rules.

💡 Vision

We believe founders, startups, and businesses should focus on product, not payments and tax compliance.

Anyhive will become the global abstraction layer for payments and compliance — PSP‑agnostic, tax‑aware, and programmable — so teams can ship, scale, and switch providers without fear. Think Stripe-like developer experience, but available for every country’s PSP and tax system.

✨ Features

  • Zero‑friction integration: Keep your code. Add a few lines to gate content or track usage.

  • No lock‑in: Swap PSPs, export data, and evolve pricing without rewrites.

  • Production‑grade UX: Modern defaults (Minimal, Neobrutal) with simple theming or full control via data‑attributes.

  • 📦 Merchant of Record Layer → We handle compliance and payouts for you.

  • 💳 Billing Support → One-time, recurring subscriptions, and usage-based billing.

  • 🌍 Tax Compliance → Integrated with Stripe Tax, Anrok, and direct modules in specific countries.

  • 🛠 Open Source SDKs → TypeScript-first, with adapters for each PSP.

  • 🖥️ Hosted checkout & customer portals (zero-setup)

  • ⚛️ React components for embeddable, customizable UI

  • 🧩 Unified Payments API → Integrate multiple PSPs (Stripe, PayPal, LINE Pay, Momo, etc.)

Core Concepts

Anyhive allows you to:

  • Manage and display checkout and customer portals with hosted UI or embeddable components.
  • No-code upgrades, downgrades, and cancellation.
  • Deal with cross-border payments and tax compliance in one place.
  • Use Anyhive to build your own checkout and customer portals.

🏗 Example

import { useAnyhive } from "@anyhive/core"

const { charge } = useAnyhive()

// One-time payment (e.g. LINE Pay in Thailand)
await charge({
  amount: 1000,
  currency: "THB",
  method: "linepay",
  customer: { id: "cus_123" },
})
import { useAnyhive } from "@anyhive/core"

const { createCustomer } = useAnyhive()

// Create a customer
const customer = await createCustomer({
  name: "John Doe",
  email: "john.doe@example.com",
})


const { createSubscription } = useAnyhive()

// Create a subscription
const subscription = await createSubscription({
  customerId: customer.id,
  planId: "plan_123",
})

Content Paywall (Nex t.js, RSC)

Minimal integration with server-first gating. Two styles are supported: a one-liner helper and a manual pattern.

One-liner helper (recommended for DX)

// app/page.tsx
import { prisma } from "@/lib/prisma";
import { paywall } from "@anyhive/react/server";
import "@anyhive/react/styles.css"; // optional defaults; or import a theme:
// import "@anyhive/react/themes/minimal.css";

export default async function Page() {
  const { render } = await paywall(() => prisma.posts.findMany());

  return (
    <section>
      <h2>Posts</h2>
      {render((posts) => (
        <ul>
          {posts.map((p) => (
            <li key={p.id}>
              <strong>{p.title}</strong>
              <div>{p.content}</div>
            </li>
          ))}
        </ul>
      ))}
    </section>
  );
}

Manual (keep explicit control, same server-first behavior)

// app/page.tsx
import { prisma } from "@/lib/prisma";
import { anyhive } from "anyhive"; // server facade
import { PaywallOverlay, EmptyPlaceholder, AccessBanner } from "@anyhive/react/client";

export default async function Page() {
  const { fetchIfAllowed, status } = anyhive.authorize();
  const { allowed, data } = await fetchIfAllowed(() => prisma.posts.findMany());

  return (
    <section>
      <h2>Posts</h2>
      <AccessBanner status={status} />
      {!allowed ? (
        <PaywallOverlay href="/pricing">
          <ul>
            <li><strong>Post title example</strong><div>Post preview content…</div></li>
            <li><strong>Post title example</strong><div>Post preview content…</div></li>
          </ul>
        </PaywallOverlay>
      ) : data.length === 0 ? (
        <EmptyPlaceholder />
      ) : (
        <ul>
          {data.map((p: { id: number; title: string; content: string }) => (
            <li key={p.id}>
              <strong>{p.title}</strong>
              <div>{p.content}</div>
            </li>
          ))}
        </ul>
      )}
    </section>
  );
}

CLI

The Anyhive CLI helps you initialize projects and set up a local development environment.

Installation

The CLI is included in this monorepo. In a standalone setup it can be installed globally:

npm i -g anyhive

Global options

  • --env <sandbox|production>: Select target environment for commands
  • --sandbox: Alias of --env sandbox

Environment resolution priority:

  1. CLI flags (--env or --sandbox)
  2. Environment variable ANYHIVE_MODE
  3. Default: production

Commands

init

Initialize an Anyhive project configuration.

anyhive init --workspace <id> --token <installToken> [--dir <path>] [--force] [--env sandbox|production]

Notes:

  • Creates anyhive.config.json in the target directory
  • Respects --env to set the initial mode field (e.g. sandbox or production)

verify

Verify your installation (demo output).

anyhive verify [--env sandbox|production]

whoami

Display the current user and environment (demo output).

anyhive whoami [--env sandbox|production]

sandbox

Create or update a local .env with a sandbox publishable key for local testing.

anyhive sandbox [--dir <path>] [--key <publishableKey>] [--force] [--write-all]

Options:

  • --dir <path>: Directory for the .env file (default: current directory)
  • --key <publishableKey>: Provide a specific key instead of generating one
  • --force: Overwrite existing ANYHIVE_PUBLISHABLE_KEY in .env
  • --write-all: Also upsert the following variables:
    • ANYHIVE_MODE=sandbox
    • ANYHIVE_API_BASE_URL=https://sandbox.api.anyhive.dev
    • ANYHIVE_WORKSPACE_ID=ws_sandbox_demo

Examples:

anyhive init --workspace ws_123 --token it_456 --env sandbox
anyhive verify --env sandbox
anyhive sandbox --dir . --write-all

Tech Stack

Server

Client

Self-hosting

Anyhive is open-source and self-hostable. Our goal is to make it easy to self-host and you won't be locked-in, and to make it easy to integrate with your own payment service provider.

For the self-hosted version, we will make it easy to deploy to Cloudflare Workers or Vercel.

📣 Get Involved

  • ⭐ Star this repo
  • 💬 Join the community on Discord
  • 🛠 Try the SDK, open issues, and contribute PSP adapters