CommunityProgramación y desarrollogithub.com

clerk/clerk-facturacion

Gestión de suscripciones con Clerk Billing: renderiza la tabla de precios y el cajón de pago integrado de Clerk, configura planes de suscripción, planes con límite de asientos para B2B, derechos de funciones con has(), y webhooks de facturación. Ideal para monetización SaaS, control de acceso por plan, flujos de pago, pruebas, facturación y gestión del ciclo de vida de suscripciones.

¿Qué es clerk-facturacion?

Clerk Billing es una habilidad diseñada para desarrolladores que integran funcionalidades de suscripción y facturación en sus aplicaciones SaaS. Permite renderizar la tabla de precios de Clerk (`PricingTable`) y un cajón de pago integrado para gestionar suscripciones desde la interfaz de usuario. Soporta planes con límite de asientos (útil para modelos B2B), derechos de funciones mediante el método `has()` para control de acceso granular, y webhooks de facturación para eventos como creación, actualización o cancelación de suscripciones. Ideal para implementar monetización SaaS, gating de planes, flujos de checkout, períodos de prueba, facturación y gestión completa del ciclo de vida de suscripciones. Compatible con Clerk como plataforma de autenticación y gestión de usuarios.

Compatible con~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/clerk/skills/tree/main/skills/clerk-billing

Installed? Explore more Programación y desarrollo skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Preguntar en tu IA favorita

Abre un nuevo chat con esta habilidad de agente ya precargada.

Documentación

¿Qué hace clerk-facturacion?

Gestión de suscripciones con Clerk Billing: renderiza la tabla de precios y el cajón de pago integrado de Clerk, configura planes de suscripción, planes con límite de asientos para B2B, derechos de funciones con has(), y webhooks de facturación. Ideal para monetización SaaS, control de acceso por plan, flujos de pago, pruebas, facturación y gestión del ciclo de vida de suscripciones.

Funcionalidades

  • Tabla de precios (PricingTable): Renderiza una tabla visual de planes de suscripción que los usuarios pueden seleccionar.
  • Cajón de pago integrado (checkout): Abre un cajón en la aplicación para completar el proceso de pago sin redirigir al usuario.
  • Planes con límite de asientos: Configura planes que limitan la cantidad de miembros (útil para equipos y empresas B2B).
  • Derechos de funciones: Usa has() para verificar si un usuario tiene acceso a funciones específicas según su plan.
  • Webhooks de facturación: Recibe eventos como subscription.created, subscription.updated, subscription.cancelled, etc., para sincronizar el estado de suscripciones en tu backend.
  • Gestión del ciclo de vida: Soporta pruebas gratuitas, facturación recurrente, cancelaciones y actualizaciones de plan.

Requisitos

  • Una cuenta en Clerk con el plan Billing habilitado.
  • Configurar un proveedor de pagos (Stripe, etc.) en el panel de Clerk.
  • Instalar el paquete @clerk/clerk-react (o @clerk/nextjs para Next.js) y @clerk/clerk-billing.

Uso básico

1. Renderizar la tabla de precios

import { ClerkProvider, SignedIn, SignedOut } from '@clerk/clerk-react';
import { PricingTable } from '@clerk/clerk-billing';

function PricingPage() {
  return (
    <>
      <SignedIn>
        <PricingTable />
      </SignedIn>
      <SignedOut>
        <p>Por favor, inicia sesión para ver los planes.</p>
      </SignedOut>
    </>
  );
}

2. Control de acceso con has()

import { useUser } from '@clerk/clerk-react';

function FeatureGate({ feature }) {
  const { user } = useUser();
  const hasFeature = user?.has({ permission: feature });

  if (!hasFeature) {
    return <p>Esta función requiere una suscripción.</p>;
  }

  return <p>Función disponible.</p>;
}

3. Manejar webhooks de facturación

Configura un endpoint en tu backend para recibir eventos de Clerk Billing:

import { Webhook } from 'svix';

export async function POST(request: Request) {
  const payload = await request.json();
  const webhook = new Webhook(process.env.CLERK_WEBHOOK_SECRET!);

  try {
    const event = webhook.verify(payload, request.headers);
    // Manejar eventos como 'subscription.created', 'subscription.updated', etc.
    console.log('Evento recibido:', event);
    return new Response('OK', { status: 200 });
  } catch (err) {
    return new Response('Error de verificación', { status: 400 });
  }
}

Documentación adicional

Para más detalles, consulta la documentación oficial de Clerk Billing.

Individual skills in this repo

This repo contains 19 individual skills — each has its own dedicated page.

clerk/clerk

Clerk authentication router. Use when user asks about adding authentication, setting up Clerk, custom sign-in flows, Swift or native iOS auth, native Android auth, Next.js patterns, React patterns, Vue patterns, Nuxt patterns, Astro patterns, TanStack Start patterns, Expo patterns, React Router patterns, Chrome Extension patterns, organizations, billing, subscriptions, payments, pricing, plans, seat-based pricing, feature entitlements, syncing users, or testing. Automatically routes to the specific skill based on their task.

clerk/clerk-android

Implement Clerk authentication for native Android apps using Kotlin and Jetpack Compose with clerk-android source-guided patterns. Use for prebuilt AuthView/UserButton or custom API-driven auth flows. Do not use for Expo or React Native projects.

clerk/clerk-astro-patterns

Astro patterns with Clerk — middleware, SSR pages, island components, API routes, static vs SSR rendering. Triggers on: astro clerk, clerk astro middleware, astro protected page, clerk island component, astro API route auth, clerk astro SSR.

clerk/clerk-backend-api

Clerk Backend REST API explorer and executor. Browse tags, inspect endpoint schemas, and execute authenticated requests. Use when listing users, managing organizations, or calling any Clerk API endpoint.

clerk/clerk-chrome-extension-patterns

Chrome Extension auth with @clerk/chrome-extension -- popup/sidepanel setup, syncHost for OAuth/SAML via web app, createClerkClient for service workers and headless extensions, stable CRX ID. Triggers on: Chrome extension auth, Plasmo clerk, popup sign-in, syncHost, background service worker token, createClerkClient, headless extension.

clerk/clerk-custom-ui

Custom authentication flows and component appearance - hooks (useSignIn, useSignUp), themes, colors, fonts, CSS. Use for custom sign-in/sign-up flows, appearance styling, visual customization, branding.

clerk/clerk-expo

Implement Clerk authentication for Expo and React Native apps using @clerk/expo source-guided patterns. Use for prebuilt AuthView/UserButton or custom hook-driven auth flows. Do not use for native iOS/Swift, native Android/Kotlin, or web framework projects.

clerk/clerk-expo-patterns

Expo / React Native patterns with Clerk — SecureStore token cache, OAuth deep linking, useAuth in native, Expo Router protected routes, push notifications with user context. Triggers on: expo clerk, clerk react native, SecureStore token cache, expo router auth, OAuth deep link clerk, mobile auth clerk.

clerk/clerk-nextjs-patterns

Advanced Next.js patterns - middleware, Server Actions, caching with Clerk.

clerk/clerk-nuxt-patterns

Nuxt 3 auth patterns with @clerk/nuxt - middleware, composables, server API routes, SSR. Triggers on: Nuxt auth, useAuth composable, clerkMiddleware Nuxt, server API Clerk, Nuxt route protection.

clerk/clerk-orgs

Clerk Organizations for B2B SaaS - create multi-tenant apps with org switching, role-based access, verified domains, and enterprise SSO. Use for team workspaces, RBAC, org-based routing, member management.

clerk/clerk-react-patterns

React SPA auth patterns with @clerk/react for Vite/CRA - ClerkProvider setup, useAuth/useUser/useClerk hooks, React Router protected routes, custom sign-in flows. Triggers on: Vite Clerk setup, React Router auth, useAuth hook, protected route, custom sign-in form React.

clerk/clerk-react-router-patterns

React Router v7 patterns with Clerk — rootAuthLoader, getAuth in loaders, clerkMiddleware, protected routes, SSR user data, org switching. Triggers on: react-router auth, rootAuthLoader, getAuth loader, react-router protected route, loader authentication, SSR auth react-router.

clerk/clerk-setup

Add Clerk authentication to any project by following the official quickstart guides.

clerk/clerk-swift

Implement Clerk authentication for native Swift and iOS apps using ClerkKit and ClerkKitUI source-guided patterns. Use for prebuilt AuthView or custom native flows. Do not use for Expo or React Native projects.

clerk/clerk-tanstack-patterns

TanStack React Start auth patterns with @clerk/tanstack-react-start - createServerFn, beforeLoad guards, loaders, Vinxi server. Triggers on: TanStack auth, createServerFn clerk, beforeLoad protection, TanStack Start middleware.

clerk/clerk-testing

E2E testing for Clerk apps. Use with Playwright or Cypress for auth flow tests.

clerk/clerk-vue-patterns

Vue 3 patterns with Clerk — composables (useAuth, useUser, useClerk, useOrganization), Vue Router guards, Pinia auth store integration. Triggers on: vue clerk, useAuth vue, clerk composables, vue router clerk guard, pinia auth clerk. For Nuxt, use clerk-nuxt-patterns instead.

clerk/clerk-webhooks

Clerk webhooks for real-time events and data syncing. Verify with verifyWebhook from the framework-specific package. Handle user, session, organization, billing, and payment events. Build event-driven features like database sync, notifications, and integrations.

Skills relacionados