Integrate Freemius Billing and Monetization with Antigravity CLI
In this guide, you will learn how to set up Antigravity CLI to integrate Freemius monetization, checkout, entitlements, and customer portal features into your SaaS product.
Preparation
- Register through the Freemius Developer Dashboard and create a product.
- Follow our plans and pricing documentation to configure your plans, prices, and plan features.
- Follow the Antigravity CLI Getting Started guide if you have not installed or configured the CLI.
- Open a terminal in your project, run
agy, and complete the workspace trust prompt when asked.
Install Freemius Skills
From the project root, run the following command:
- npm
- Yarn
- pnpm
- Bun
npx skills add freemius/freemius-ai
yarn dlx skills add freemius/freemius-ai
pnpm dlx skills add freemius/freemius-ai
bun x skills add freemius/freemius-ai
Select Antigravity CLI and install all the Freemius skills when prompted to get the complete checkout, entitlement, and customer portal workflow.
Set Your Freemius API Key
On the Settings → API & Keys page, copy the .env file under Usage examples and save it in your project root.
Never commit the .env file to your repository. Store production credentials in your deployment platform's secrets manager.
Prompt Your First Integration
Prompt Antigravity CLI with a brief description of how you want to integrate Freemius and gate premium features behind a paywall. For example:
Integrate Freemius monetization into my software. I want to offer subscriptions with multiple plans for continued access and top-up plans for purchasing additional credits. Use the relevant Freemius skills. The .env file already contains the secrets needed to connect to the Freemius platform. You can query the Freemius API directly with the Freemius JS SDK to find the pricing IDs of the relevant plans. First inspect the existing application and propose an integration plan. After I approve the plan, implement it and run the relevant tests.Antigravity CLI will use the installed skills and your Freemius product configuration to implement the relevant pricing table, checkout, entitlements, top-up credits, and customer portal features. It may also create or update a top-level AGENTS.md file with instructions for maintaining the integration.
For a complex product setup, first ask Antigravity CLI to inspect the codebase and propose an implementation plan. Review the proposed architecture, especially the authentication, entitlement storage, webhook handling, and checkout flow, before approving changes or tool calls.
Explain whether you sell subscriptions, top-up credits, or both. Also mention whether a user can hold more than one subscription and where premium access must be enforced.
Complete the Dashboard Setup
After implementing the integration, Antigravity CLI may ask you to configure URLs in the Freemius Developer Dashboard:
- Go to Settings → Checkout & Redirection to configure the post-checkout redirection URL.
- Go to Settings → Webhooks to add the webhook endpoint created for your application.
Use the exact URLs and events that Antigravity CLI reports for your implementation.
Test the Integration
Antigravity CLI should adapt the Freemius integration to your application's existing structure. Verify that it created or updated the following features:
-
Pricing Table: A pricing experience that displays the plans, prices, billing cycles, and features configured for your Freemius product.
-
Checkout: A purchase flow that opens Freemius Checkout with the selected plan and returns the user to your application after a successful purchase.
-
Entitlements and Paywalls: Backend and frontend checks that protect premium features, show a paywall to users without access, and grant access after the appropriate entitlement is received.
-
Account Page and Customer Portal: An added or updated account area that displays relevant subscription or purchase information and gives users access to the Freemius Customer Portal.
Test these features with users who have and do not have active entitlements. Also verify that checkout redirection and webhook events update access and account information correctly.
Troubleshooting and Updates
If the integration does not work as expected, describe the observed and expected behavior and ask Antigravity CLI to use the freemius-troubleshooting skill. Before troubleshooting, update the installed skills:
npx skills update -y
For more information, examples, and best practices, see the Freemius Skills documentation.