@freemius/checkout

中文文档
1.5.1发布于 2026/09/15MITTypeScriptESM + CJS零依赖近 30 天下载 1.4万

Zero-dependency TypeScript SDK to embed Freemius Checkout in SaaS apps: secure buy button, user_token prefill, trials, coupons, multi-currency, i18n, callbacks. ESM/CJS.

原始使用文档

FREEMIUS CHECKOUT JAVASCRIPT SDK

npm version NPM Downloads Twitter

A modern, API-driven, JavaScript-based checkout app for Freemius sellers .

Freemius Checkout app screenshot

Usage Guide

The Freemius Checkout JS SDK is available both in a CDN version and as an npm package. This guide covers usage via the npm package. We assume you already have a bundler like vite or webpack to manage your app.

  1. Install the official npm package.

    npm i @freemius/checkout
    
    # If using yarn
    yarn add @freemius/checkout
    
  2. Add the given HTML to your app:

    <select id="licenses">
        <option value="1" selected="selected">Single Activation License</option>
        <option value="2">2-Activations License</option>
        <option value="unlimited">Unlimited Activations License</option>
    </select>
    <button id="purchase">Buy Button</button>
    
  3. Add the JavaScript code to handle the purchase:

    import { Checkout } from '@freemius/checkout';
    
    // Instantiate the Checkout
    const checkout = new Checkout({
        product_id: '123456',
    });
    
    document.querySelector('#purchase').addEventListener('click', (e) => {
        e.preventDefault();
    
        checkout.open({
            name: 'My Awesome Product',
            licenses: getSelectedLicenses(),
            purchaseCompleted: (response) => {
                console.log('Purchase completed:', response);
            },
            success: (response) => {
                console.log(
                    'Checkout closed after successful purchase:',
                    response
                );
            },
        });
    });
    
    function getSelectedLicenses() {
        return document.querySelector('#licenses').value;
    }
    

To learn more about the CDN, checkout API and its usage, visit the Freemius Docs.

Contributing

This project is open source, and we welcome contributions. See the contribution guide.

版本与发布记录

@freemius/checkout 共发布 26 个版本,首次发布于 2024/09/13;过去 12 个月发布了 2 个版本。

版本发布日期距今
1.5.1latest2026/09/152 个月前
1.5.02026/08/063 个月前
1.4.12025/11/121 年前
1.4.02025/10/261.1 年前
1.3.1next2025/09/181.2 年前
1.3.1-alpha.42025/08/201.2 年前

关于 @freemius/checkout 的常见问题

@freemius/checkout 是什么?

Zero-dependency TypeScript SDK to embed Freemius Checkout in SaaS apps: secure buy button, user_token prefill, trials, coupons, multi-currency, i18n, callbacks. ESM/CJS.

如何安装 @freemius/checkout?

在项目目录运行 npm install @freemius/checkout,或使用 pnpm add / yarn add / bun add。

@freemius/checkout 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@freemius/checkout 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@freemius/checkout 可以商用吗?

@freemius/checkout 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@freemius/checkout 的下载量有多少?

根据 npm 官方下载统计,@freemius/checkout 在 2026/10/16 – 2026/11/14 这 30 天内被下载 14,390 次,日均约 480 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@freemius/checkout 还在维护吗?

最新版本 1.5.1 发布于 2026/09/15(2 个月前);至今共发布 26 个版本,其中过去 12 个月发布了 2 个;首次发布于 2024/09/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。