### Next.js Example App Setup Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/README.md Commands to set up and run the example Next.js application, including installation, environment variable configuration, and database migration. ```bash pnpm install && pnpm run build cd examples/nextjs cp .env.example .env.local # fill in your Creem test API key pnpm migrate pnpm dev ``` -------------------------------- ### Run the Example App Source: https://github.com/armitage-labs/creem/blob/main/packages/nextjs/README.md Navigate to the example directory, install its dependencies, and run the example application using npm. This allows you to see the adaptor in action. ```bash # Run example app cd example npm install npm run dev ``` -------------------------------- ### Initial Project Setup Commands Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/test/nextjs-app/PROJECT_OVERVIEW.md Provides the necessary bash commands to install dependencies, build the parent plugin, configure environment variables, and start the development server. ```bash # 1. Install dependencies npm install # 2. Build parent plugin npm run build:plugin # 3. Configure environment cp .env.local.example .env.local # Edit .env.local with your credentials # 4. Start development server npm run dev ``` -------------------------------- ### Development Setup for Creem Next.js Example Source: https://github.com/armitage-labs/creem/blob/main/packages/creem-io/README-EXAMPLE.md Commands to clone the repository, install dependencies, build the library, and run the example application for local development. ```bash # Clone the repository git clone https://github.com/yourusername/creem-nextjs.git # Install dependencies npm install # Build the library npm run build # Run example app cd example npm install npm run dev ``` -------------------------------- ### Install and Run Test App Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/test/nextjs-app/QUICK_START.md Navigate to the test app directory, install dependencies, build the plugin, configure environment variables, and start the development server. ```bash cd test/nextjs-app npm run setup cp .env.local.example .env.local # Edit .env.local with your Creem API key npm run dev ``` -------------------------------- ### Install and Run Docs Locally Source: https://github.com/armitage-labs/creem/blob/main/README.md Instructions for installing the Mintlify CLI and starting the local development server for the project's documentation. ```bash # Install Mintlify CLI npm i -g mintlify # Start local dev server cd packages/docs mintlify dev ``` -------------------------------- ### Start Next.js Dev Server (Example Directory) Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/examples/nextjs/README.md Start the Next.js development server from within the examples/nextjs directory. ```bash # Or from this directory: pnpm dev ``` -------------------------------- ### Install Dependencies and Run Local Development Servers Source: https://github.com/armitage-labs/creem/blob/main/packages/convex/CONTRIBUTING.md Installs project dependencies and starts the Svelte and React development servers. ```sh pnpm i pnpm dev:svelte pnpm dev:react ``` -------------------------------- ### Install @creem_io/react Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/features/checkout/embedded-checkout.mdx Install the React SDK using npm, yarn, pnpm, or bun. ```bash npm install @creem_io/react ``` ```bash yarn add @creem_io/react ``` ```bash pnpm add @creem_io/react ``` ```bash bun add @creem_io/react ``` -------------------------------- ### AI Agent Setup Prompt Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/getting-started/introduction.mdx Provide this prompt to an AI coding assistant to automate Creem setup, including CLI installation, authentication, product creation, and store monitoring. ```text Read https://creem.io/SKILL.md and set up Creem for me ``` -------------------------------- ### Install Mintlify CLI Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/README.md Install the Mintlify CLI globally to preview documentation changes locally. ```bash npm i -g mintlify ``` -------------------------------- ### Install @creem_io/vue Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/features/checkout/embedded-checkout.mdx Install the Vue SDK using npm, yarn, pnpm, or bun. ```bash npm install @creem_io/vue ``` ```bash yarn add @creem_io/vue ``` ```bash pnpm add @creem_io/vue ``` ```bash bun add @creem_io/vue ``` -------------------------------- ### Install Better Auth and Creem Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/QUICK_START.md Install the necessary packages using npm. ```bash npm install @creem_io/better-auth better-auth creem ``` -------------------------------- ### Creem Client Setup (Next.js App Router) Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/getting-started/quickstart.mdx This example shows how to set up the Creem client within a Next.js App Router project, including environment variable configuration. ```APIDOC ## Creem Client Setup ### Description Configures the Creem client for use in a Next.js application, typically in `lib/creem.ts`. ### Environment Variables Ensure the following environment variables are set in your `.env.local` file: ``` CREEM_API_KEY=creem_test_your_api_key CREEM_WEBHOOK_SECRET=whsec_your_webhook_secret NEXT_PUBLIC_APP_URL=http://localhost:3000 ``` ### Code Example ```typescript // lib/creem.ts import { createCreem } from 'creem_io'; export const creem = createCreem({ apiKey: process.env.CREEM_API_KEY!, testMode: true, // Set to false for production }); ``` ``` -------------------------------- ### Client Setup (Standard) Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/README.md Standard client setup for Better Auth with the Creem plugin. ```APIDOC ## Client Setup (Standard) ### Description Sets up the standard Better Auth client with the Creem plugin. ### Usage ```typescript // lib/auth-client.ts import { createAuthClient } from "better-auth/react"; import { creemClient } from "@creem_io/better-auth/client"; export const authClient = createAuthClient({ baseURL: process.env.NEXT_PUBLIC_APP_URL, plugins: [creemClient()] }); ``` ``` -------------------------------- ### Install and Run ngrok Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/test/nextjs-app/SETUP.md Install ngrok and use it to expose your local development server to the internet for webhook testing. ```bash # Install ngrok brew install ngrok # macOS # or download from https://ngrok.com/ # Run ngrok ngrok http 3000 # Copy the HTTPS URL (e.g., https://abc123.ngrok.io) # Configure this in your Creem dashboard webhook settings ``` -------------------------------- ### Client Setup (Improved TypeScript Support) Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/README.md Client setup with improved TypeScript support using `createCreemAuthClient`. ```APIDOC ## Client Setup (Improved TypeScript Support) ### Description Provides enhanced TypeScript support and cleaner IntelliSense for the Better Auth client, specifically designed for the Creem plugin. ### Usage ```typescript // lib/auth-client.ts import { createCreemAuthClient } from "@creem_io/better-auth/create-creem-auth-client"; import { creemClient } from "@creem_io/better-auth/client"; export const authClient = createCreemAuthClient({ baseURL: process.env.NEXT_PUBLIC_APP_URL, plugins: [creemClient()] }); ``` **Note:** This wrapper is primarily for the Creem plugin and may not support all other BetterAuth plugins. ``` -------------------------------- ### Build and Run Example App Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/CONTRIBUTING.md Build the project and run the example Next.js app using pnpm workspaces. This ensures the local build of @creem_io/better-auth is used. ```bash pnpm run build pnpm --filter examples-nextjs dev ``` -------------------------------- ### Install Dependencies Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/test/nextjs-app/README.md Run this command in the project root to install all necessary npm packages. ```bash npm install ``` -------------------------------- ### Run Example Script Source: https://github.com/armitage-labs/creem/blob/main/packages/creem-sdk/examples/README.md Builds the project and then runs an example TypeScript file using tsx. ```bash npm run build && npx tsx example.ts ``` -------------------------------- ### Install @creem_io/nextjs with bun Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/code/sdks/nextjs.mdx Install the official Creem Next.js adapter using bun. ```bash bun install @creem_io/nextjs ``` -------------------------------- ### Install @creem_io/svelte Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/features/checkout/embedded-checkout.mdx Install the Svelte SDK using npm, yarn, pnpm, or bun. ```bash npm install @creem_io/svelte ``` ```bash yarn add @creem_io/svelte ``` ```bash pnpm add @creem_io/svelte ``` ```bash bun add @creem_io/svelte ``` -------------------------------- ### Client Setup (Improved TypeScript) Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/README.md Client setup using `createCreemAuthClient` for enhanced TypeScript support and cleaner IntelliSense. Primarily for the Creem plugin. ```typescript // lib/auth-client.ts import { createCreemAuthClient } from "@creem_io/better-auth/create-creem-auth-client"; import { creemClient } from "@creem_io/better-auth/client"; export const authClient = createCreemAuthClient({ baseURL: process.env.NEXT_PUBLIC_APP_URL, plugins: [creemClient()] }); // Now you get the cleanest possible type hints! ``` -------------------------------- ### Install and Run Next.js App Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/test/README.md Steps to install dependencies, configure environment variables, and run the Next.js test application. ```bash cd nextjs-app npm install cp .env.local.example .env.local # Edit .env.local with your credentials npm run dev ``` -------------------------------- ### Install Creem SDK with Bun Source: https://github.com/armitage-labs/creem/blob/main/packages/creem-sdk/README.md Install the Creem SDK using the Bun package manager. ```bash bun add creem ``` -------------------------------- ### Server Action Example Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/README.md Example of using `createCheckout` in a Next.js Server Action to initiate a checkout process for a product. ```APIDOC ## Server Action Example ### Description Example of using `createCheckout` in a Next.js Server Action to initiate a checkout process for a product. This redirects the user to the Creem checkout page. ### Code ```typescript // app/actions.ts "use server"; import { createCheckout } from "@creem_io/better-auth/server"; import { auth } from "@/lib/auth"; import { headers } from "next/headers"; import { redirect } from "next/navigation"; export async function startCheckout(productId: string) { const session = await auth.api.getSession({ headers: await headers() }); if (!session?.user) { throw new Error("Not authenticated"); } const { url } = await createCheckout( { apiKey: process.env.CREEM_API_KEY!, testMode: true, }, { productId, customer: { email: session.user.email }, successUrl: "/success", metadata: { userId: session.user.id }, }, ); redirect(url); } ``` ``` -------------------------------- ### Start Next.js Dev Server (Repo Root) Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/examples/nextjs/README.md Start the Next.js development server from the repository root, filtering for the examples-nextjs package. ```bash # From repo root: pnpm --filter examples-nextjs dev ``` -------------------------------- ### Install Creem CLI with npm Source: https://github.com/armitage-labs/creem/blob/main/packages/cli/README.md Install the Creem CLI globally using npm. ```bash npm install -g creem-cli ``` -------------------------------- ### Install CREEM Lightweight Wrapper Source: https://github.com/armitage-labs/creem/blob/main/README.md Install the lightweight, framework-agnostic wrapper SDK for CREEM. It has zero dependencies. ```bash npm install creem_io ``` -------------------------------- ### Install Dependencies with pnpm Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/examples/nextjs/README.md Install project dependencies from the repository root using pnpm. ```bash pnpm install ``` -------------------------------- ### Product List Response Example Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/skills/creem-api/REFERENCE.md Example of a paginated response for listing products, including items and pagination details. ```json { "items": [ /* ProductEntity[] */ ], "pagination": { "total_records": 25, "total_pages": 3, "current_page": 1, "next_page": 2, "prev_page": null } } ``` -------------------------------- ### Start the Development Server Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/code/sdks/templates.mdx Start the Next.js development server to run the application locally. This command allows for hot-reloading and development features. ```bash yarn dev ``` -------------------------------- ### Clone Repo and Install Dependencies Source: https://github.com/armitage-labs/creem/blob/main/README.md Steps to clone the Creem repository, navigate into the directory, and install project dependencies using pnpm. ```bash # Clone the repo git clone https://github.com/armitage-labs/creem.git cd creem # Install dependencies pnpm install ``` -------------------------------- ### Install Next.js Adapter Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/features/checkout/checkout-api.mdx Install the Next.js adapter for Creem checkout sessions using npm, yarn, pnpm, or bun. ```bash npm install @creem_io/nextjs ``` ```bash yarn add @creem_io/nextjs ``` ```bash pnpm install @creem_io/nextjs ``` ```bash bun install @creem_io/nextjs ``` -------------------------------- ### Install and Login with Creem CLI Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/ai/introduction.mdx Install the Creem CLI using Homebrew and log in with your API key. This sets up your terminal for managing your Creem store. ```bash brew tap armitage-labs/creem && brew install creem creem login --api-key creem_test_YOUR_KEY_HERE ``` -------------------------------- ### Set Up Environment Variables Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/code/sdks/templates.mdx Copy the example environment file and fill in the required variables. Ensure all necessary API keys and configurations are present in your .env file. ```bash cp .env.example .env # Edit .env and fill in the required variables ``` -------------------------------- ### Install Creem Better Auth Plugin Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/BETTERAUTH.md Install the Creem plugin for Better Auth using npm or yarn. Ensure installation in both client and server if using a separate setup. ```bash npm install @creem_io/better-auth # or yarn add @creem_io/better-auth ``` -------------------------------- ### Install Creem Skills via Claude Marketplace Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/ai/for-agents/skill-files.mdx Install the Creem skills package directly from the Claude Marketplace for a streamlined setup. ```bash /plugin marketplace add armitage-labs/creem-skills /plugin install creem-api@creem-skills ``` -------------------------------- ### Basic Webhook Setup with Event Handling Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/code/sdks/typescript-wrapper.mdx Illustrates how to set up a webhook endpoint using the SDK, including automatic signature verification and handling various event types like `onCheckoutCompleted`. ```typescript import { createCreem } from 'creem_io'; const creem = createCreem({ apiKey: process.env.CREEM_API_KEY!, webhookSecret: process.env.CREEM_WEBHOOK_SECRET!, }); // In your webhook endpoint app.post('/webhook', async (req, res) => { try { await creem.webhooks.handleEvents( req.body, // raw body as string req.headers['creem-signature'], { onCheckoutCompleted: async (data) => { console.log('Checkout completed:', data.customer?.email); }, onGrantAccess: async (context) => { // Grant user access when subscription is active/trialing/paid const userId = context.metadata?.userId; await grantUserAccess(userId); }, onRevokeAccess: async (context) => { // Revoke access when subscription is paused/expired const userId = context.metadata?.userId; await revokeUserAccess(userId); }, } ); res.status(200).send('OK'); } catch (error) { console.error('Webhook error:', error); res.status(400).send('Invalid signature'); } }); ``` -------------------------------- ### ProductEntity Example Source: https://github.com/armitage-labs/creem/blob/main/packages/creem-sdk/docs/models/components/productentity.md Demonstrates how to instantiate and populate a ProductEntity object with sample data. Ensure all required fields are correctly formatted. ```typescript import { ProductEntity } from "creem/models/components"; let value: ProductEntity = { id: "", mode: "test", object: "", name: "", description: "This is a sample product description.", imageUrl: "https://example.com/image.jpg", features: [ { id: "feat_abc123", type: "licenseKey", description: "Access to premium course materials.", }, ], price: 400, currency: "USD", billingType: "onetime", billingPeriod: "every-three-months", status: "archived", taxMode: "inclusive", taxCategory: "ebooks", productUrl: "https://creem.io/product/prod_123123123123", defaultSuccessUrl: "https://example.com/?status=successful", createdAt: new Date("2023-01-01T00:00:00Z"), updatedAt: new Date("2023-01-01T00:00:00Z"), }; ``` -------------------------------- ### CancelSubscriptionRequest Example Source: https://github.com/armitage-labs/creem/blob/main/packages/creem-sdk/docs/models/operations/cancelsubscriptionrequest.md Demonstrates how to create an instance of CancelSubscriptionRequest in TypeScript. Ensure the 'creem' package is installed. ```typescript import { CancelSubscriptionRequest } from "creem/models/operations"; let value: CancelSubscriptionRequest = { id: "", cancelSubscriptionRequestEntity: { mode: "immediate", onExecute: "cancel", }, }; ``` -------------------------------- ### Get Latest Transaction ID Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/ai/for-agents/cli.mdx Retrieves the ID of the most recent transaction. Ensure `jq` is installed for JSON parsing. ```bash # Get the latest transaction ID LATEST=$(creem transactions list --limit 1 --json | jq -r '.[0].id') echo "Latest transaction: $LATEST" ``` -------------------------------- ### Get and List Transactions Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/code/sdks/typescript-wrapper.mdx Provides examples for retrieving a specific transaction by its ID and listing transactions, with optional filtering by customer ID and pagination controls. ```typescript // Get a transaction const transaction = await creem.transactions.get({ transactionId: 'txn_xxxxx', }); // List transactions const transactions = await creem.transactions.list({ customerId: 'cust_xxxxx', // Optional: filter by customer page: 1, limit: 50, }); ``` -------------------------------- ### Create Environment File Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/test/nextjs-app/SETUP.md Copy the example environment file to create a new local environment file. ```bash cp .env.local.example .env.local ``` -------------------------------- ### Clone the Creem Next.js Template Repository Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/code/sdks/templates.mdx Clone the official Creem Next.js template repository to start building your application. Navigate into the cloned directory to proceed with setup. ```bash git clone https://github.com/armitage-labs/creem-template.git cd creem-template ``` -------------------------------- ### Create a New Product Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/ai/for-agents/cli.mdx Create a new product with specified name, description, price, currency, billing type, and billing period. ```bash creem products create \ --name "Pro Plan" \ --description "Monthly pro subscription with all features" \ --price 1999 \ --currency USD \ --billing-type recurring \ --billing-period every-month ``` -------------------------------- ### Update Subscription Seat Count Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/features/subscriptions/managing.mdx This section provides examples for updating the number of seats for a subscription using both the TypeScript SDK and the REST API. It includes steps to first retrieve the subscription to get the item ID, and then perform the update. ```APIDOC ## Update Subscription Seat Count This operation allows you to update the number of seats for a subscription. You will need the `subscriptionId` and the `itemId` of the subscription item you wish to update. The `units` field specifies the new seat count. ### TypeScript SDK ```typescript import { createCreem } from 'creem_io'; const creem = createCreem({ apiKey: process.env.CREEM_API_KEY!, testMode: process.env.NODE_ENV !== 'production', }); // First, get the subscription to retrieve the item ID const subscription = await creem.subscriptions.get({ subscriptionId: 'sub_YOUR_SUBSCRIPTION_ID', }); const itemId = subscription.items[0].id; // Update the seat count const updated = await creem.subscriptions.update({ subscriptionId: 'sub_YOUR_SUBSCRIPTION_ID', items: [ { id: itemId, units: 10, // New seat count }, ], updateBehavior: 'proration-charge-immediately', }); ``` ### REST API ```bash # First, get the subscription curl -X GET https://api.creem.io/v1/subscriptions/sub_YOUR_SUBSCRIPTION_ID \ -H "x-api-key: YOUR_API_KEY" # Then update with the item ID curl -X POST https://api.creem.io/v1/subscriptions/sub_YOUR_SUBSCRIPTION_ID \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "items": [ { "id": "sitem_ITEM_ID", "units": 10 } ] }' ``` #### Parameters ##### Request Body (REST API) - **items** (array) - Required - A list of items to update. - **id** (string) - Required - The ID of the subscription item. - **units** (integer) - Required - The new number of units (seats) for the item. ##### Request Body (TypeScript SDK) - **subscriptionId** (string) - Required - The ID of the subscription to update. - **items** (array) - Required - A list of items to update. - **id** (string) - Required - The ID of the subscription item. - **units** (integer) - Required - The new number of units (seats) for the item. - **updateBehavior** (string) - Optional - Controls how prorated charges are handled. Options include `proration-charge-immediately` and `proration-none`. ``` -------------------------------- ### Server-Side Subscription Access Check Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/code/sdks/better-auth.mdx Perform subscription access checks directly in Server Components or API routes using the server-side SDK. This example demonstrates how to get the user session and check their subscription status before rendering content. ```typescript import { checkSubscriptionAccess } from "@creem_io/better-auth/server"; import { auth } from "@/lib/auth"; import { headers } from "next/headers"; import { redirect } from "next/navigation"; export default async function DashboardPage() { const session = await auth.api.getSession({ headers: await headers() }); if (!session?.user) { redirect("/login"); } const status = await checkSubscriptionAccess( { apiKey: process.env.CREEM_API_KEY!, testMode: true, }, { database: auth.options.database, userId: session.user.id, } ); if (!status.hasAccess) { redirect("/subscribe"); } return (

Welcome to Dashboard

Subscription Status: {status.status}

); } ``` -------------------------------- ### Verify Creem CLI Installation Source: https://github.com/armitage-labs/creem/blob/main/packages/cli/AGENTS.md Check the installed version of the Creem CLI to verify the installation. ```bash creem --version ``` -------------------------------- ### Install @creem_io/embed Source: https://github.com/armitage-labs/creem/blob/main/packages/embed/README.md Install the embed package using npm. ```bash npm install @creem_io/embed ``` -------------------------------- ### Install @creem_io/vue Source: https://github.com/armitage-labs/creem/blob/main/packages/vue/README.md Install the Creem Vue package using npm. ```bash npm install @creem_io/vue ``` -------------------------------- ### Install @creem_io/react Source: https://github.com/armitage-labs/creem/blob/main/packages/react/README.md Install the Creem React package using npm. ```bash npm install @creem_io/react ``` -------------------------------- ### Install creem_io with pnpm Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/code/sdks/typescript-wrapper.mdx Install the creem_io package using pnpm. ```bash pnpm add creem_io ``` -------------------------------- ### Run Mintlify Development Server Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/README.md Run the Mintlify development server from the root of your documentation directory to preview changes. ```bash mintlify dev ``` -------------------------------- ### Install and Login with Creem CLI Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/getting-started/introduction.mdx Install the Creem CLI via Homebrew, tap the repository, and log in using your API key. Use test keys for the sandbox environment. ```bash brew tap armitage-labs/creem brew install creem creem login --api-key creem_test_YOUR_KEY ``` -------------------------------- ### Install Creem Svelte Package Source: https://github.com/armitage-labs/creem/blob/main/packages/svelte/README.md Install the @creem_io/svelte package using npm. ```bash npm install @creem_io/svelte ``` -------------------------------- ### Install @creem_io/nextjs with pnpm Source: https://github.com/armitage-labs/creem/blob/main/packages/creem-io/README-EXAMPLE.md Install the Creem Next.js package using pnpm. ```bash pnpm install @creem_io/nextjs ``` -------------------------------- ### Install @creem_io/nextjs with yarn Source: https://github.com/armitage-labs/creem/blob/main/packages/creem-io/README-EXAMPLE.md Install the Creem Next.js package using yarn. ```bash yarn add @creem_io/nextjs ``` -------------------------------- ### Page Frontmatter Example Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/CLAUDE.md Example of frontmatter required for each MDX page in the documentation. ```yaml --- title: 'Page Title' description: 'Brief description of the page content.' icon: 'icon-name' # Optional — Font Awesome icon name --- ``` -------------------------------- ### OpenAPI Configuration Examples Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/essentials/settings.mdx Configure the OpenAPI file path(s) for API documentation. Supports absolute, relative, and multiple URLs. ```json "openapi": "https://example.com/openapi.json" ``` ```json "openapi": "/openapi.json" ``` ```json "openapi": ["https://example.com/openapi1.json", "/openapi2.json", "/openapi3.json"] ``` -------------------------------- ### Create a Checkout using CLI Source: https://github.com/armitage-labs/creem/blob/main/packages/cli/AGENTS.md Use the CLI to initiate a new checkout for a product. Requires a product ID and a success URL. ```bash creem checkouts create --product prod_XXXXX --success-url https://app.com/welcome ``` -------------------------------- ### String Type Example Source: https://github.com/armitage-labs/creem/blob/main/packages/creem-sdk/docs/models/components/checkoutentitycustomer.md Example of how to represent a string value for a customer attribute. ```typescript const value: string = ""; ``` -------------------------------- ### Install Better Auth Plugin Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/features/checkout/checkout-api.mdx Install the Better Auth plugin for Creem integration. ```bash npm install @creem_io/better-auth better-auth ``` -------------------------------- ### Authentication Example Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/api-reference/introduction.mdx Demonstrates how to authenticate API requests using your API key in the `x-api-key` header. ```APIDOC ## GET /products ### Description This endpoint retrieves a list of products. ### Method GET ### Endpoint /products ### Request Example ```bash curl -X GET https://api.creem.io/v1/products \ -H "x-api-key: creem_YOUR_API_KEY" ``` ``` -------------------------------- ### Creem CLI Quick Start Commands Source: https://github.com/armitage-labs/creem/blob/main/packages/cli/README.md Authenticate, check status, and set environment mode for the Creem CLI. ```bash # Authenticate with your API key creem login # Check your auth status creem whoami # Switch to live mode creem config set environment live ``` -------------------------------- ### Get Products List in JSON Format Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/ai/for-agents/cli.mdx Retrieve a list of all products and format the output as JSON. ```bash creem products list --json ``` -------------------------------- ### Create Product Request Body Example Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/skills/creem-api/REFERENCE.md Example of a request body for creating a new product, specifying details like name, price, currency, and billing type. ```json { "name": "Pro Plan", "description": "Full access to all features", "image_url": "https://example.com/image.jpg", "price": 2900, "currency": "USD", "billing_type": "recurring", "billing_period": "every-month", "status": "active", "tax_mode": "exclusive", "tax_category": "saas", "product_url": "https://creem.io/product/prod_abc123", "default_success_url": "https://example.com/success", "features": [], "created_at": "2024-01-01T00:00:00Z", "updated_at": "2024-01-01T00:00:00Z" } ``` -------------------------------- ### Initialize Creem SDK and Retrieve Product Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/code/sdks/typescript-core.mdx Instantiate the Creem SDK with an API key and server index, then retrieve a specific product using its ID. ```typescript import { Creem } from 'creem'; const creem = new Creem({ apiKey: process.env.CREEM_API_KEY!, // 0 = production, 1 = test serverIdx: 0, }); // Retrieve a product const product = await creem.products.get('prod_7CIbZEZnRC5DWibmoOboOu'); console.log(product); ``` -------------------------------- ### Mintlify Components Example Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/CLAUDE.md Demonstrates the usage of various Mintlify components like Note, Warning, Tip, Info, CodeGroup, Card, CardGroup, Steps, Tabs, and Accordion within an MDX file. ```mdx Important information the reader should know. Critical warning about potential issues. Helpful suggestion or best practice. Additional context that may be useful. ```typescript TypeScript // TypeScript example ``` ```python Python # Python example ``` Card description text. Description Description Step content here. Step content here. Content for tab 1 Content for tab 2 Hidden content revealed on click. ``` -------------------------------- ### Conventional Commits Examples Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/CONTRIBUTING.md Examples of commit messages following the Conventional Commits specification. ```bash feat: add support for custom webhook endpoints fix: correct type inference for checkout response docs: update README with server utilities guide ``` -------------------------------- ### Run Development Server Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/test/nextjs-app/README.md Start the Next.js development server to access the application locally. The app will be available at http://localhost:3000. ```bash npm run dev ``` -------------------------------- ### Fetch and Save SKILL.md Source: https://github.com/armitage-labs/creem/blob/main/packages/docs/ai/for-agents/skill-files.mdx Demonstrates how to fetch the main skill file and save it locally for offline use. Also shows how to check the last modified date for updates. ```bash # Fetch the skill curl -s https://creem.io/SKILL.md # Save locally mkdir -p ~/.creem/skills curl -s https://creem.io/SKILL.md > ~/.creem/skills/SKILL.md # Check for updates curl -sI https://creem.io/SKILL.md | grep last-modified ``` -------------------------------- ### UI Permissions Implementation Example Source: https://github.com/armitage-labs/creem/blob/main/packages/convex/README.md Example of how to implement UI-side permissions in a Svelte component, dynamically setting permission flags based on user roles. This example shows how to control button states for billing actions. ```typescript ... ``` -------------------------------- ### Create Product using Creem CLI Source: https://github.com/armitage-labs/creem/blob/main/packages/cli/AGENTS.md Use the Creem CLI to create a new product, specifying details like name, description, price, and billing type. ```bash # CLI creem products create \ --name "Pro Plan" \ --description "Monthly pro subscription with all features" \ --price 1999 \ --currency USD \ --billing-type recurring \ --billing-period every-month \ --tax-category saas ``` -------------------------------- ### Create Account DTO Example Source: https://github.com/armitage-labs/creem/blob/main/packages/creem-sdk/docs/models/components/createaccountdto.md Demonstrates how to import and instantiate the CreateAccountDto with required and optional fields. ```typescript import { CreateAccountDto } from "creem/models/components"; let value: CreateAccountDto = { customerId: "cust_abc123", initialBalance: "300", }; ``` -------------------------------- ### Install Creem SDK with Yarn Source: https://github.com/armitage-labs/creem/blob/main/packages/creem-sdk/README.md Install the Creem SDK using the Yarn package manager. ```bash yarn add creem ``` -------------------------------- ### Install Creem SDK with PNPM Source: https://github.com/armitage-labs/creem/blob/main/packages/creem-sdk/README.md Install the Creem SDK using the pnpm package manager. ```bash pnpm add creem ``` -------------------------------- ### Install Creem SDK with NPM Source: https://github.com/armitage-labs/creem/blob/main/packages/creem-sdk/README.md Install the Creem SDK using the npm package manager. ```bash npm add creem ``` -------------------------------- ### Install CREEM SDK Source: https://github.com/armitage-labs/creem/blob/main/README.md Install the official TypeScript SDK for CREEM. This is recommended for most use cases. ```bash npm install creem ``` -------------------------------- ### Client Configuration - Standard Source: https://github.com/armitage-labs/creem/blob/main/packages/better-auth/QUICK_START.md Set up the Better Auth client using the standard `createAuthClient` for basic integration. ```typescript // lib/auth-client.ts import { createAuthClient } from "better-auth/react"; import { creemClient } from "@creem_io/better-auth/client"; export const authClient = createAuthClient({ baseURL: process.env.NEXT_PUBLIC_APP_URL, plugins: [creemClient()] }); ```