Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver ToolsFeatured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver Tools

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
Polar.sh Creator Monetization

Polar.sh Creator Monetization

Monetize open source with Polar.sh in Google Antigravity projects including sponsorships, subscriptions, and digital products.

polarmonetizationsubscriptionspaymentsopen-source
by Antigravity Team
⭐0Stars
.antigravity
# Polar.sh Creator Monetization for Google Antigravity

Monetize your open source projects and developer tools with Polar.sh in your Google Antigravity IDE projects. This comprehensive guide covers sponsorships, subscriptions, digital products, and API integration optimized for Gemini 3 agentic development.

## Polar.sh Configuration

Set up Polar.sh SDK with proper TypeScript configuration:

```typescript
// lib/polar.ts
import { Polar } from '@polar-sh/sdk';

if (!process.env.POLAR_ACCESS_TOKEN) {
  throw new Error('POLAR_ACCESS_TOKEN is not defined');
}

export const polar = new Polar({
  accessToken: process.env.POLAR_ACCESS_TOKEN,
});

export const ORGANIZATION_ID = process.env.POLAR_ORGANIZATION_ID!;

// Subscription tier configuration
export const SUBSCRIPTION_TIERS = {
  supporter: {
    name: 'Supporter',
    priceMonthly: 500, // $5.00
    priceYearly: 5000, // $50.00 (2 months free)
    benefits: [
      'Access to supporter Discord channel',
      'Name in project README',
      'Early access to new features',
    ],
  },
  professional: {
    name: 'Professional',
    priceMonthly: 2000, // $20.00
    priceYearly: 20000, // $200.00
    benefits: [
      'All Supporter benefits',
      'Priority support',
      'Access to premium prompts',
      '1-on-1 monthly call',
    ],
  },
  enterprise: {
    name: 'Enterprise',
    priceMonthly: 10000, // $100.00
    priceYearly: 100000, // $1000.00
    benefits: [
      'All Professional benefits',
      'Custom integrations',
      'Dedicated support channel',
      'SLA guarantees',
    ],
  },
} as const;

export type SubscriptionTier = keyof typeof SUBSCRIPTION_TIERS;
```

## Subscription Management

Handle subscription checkout and management:

```typescript
// app/api/subscriptions/checkout/route.ts
import { NextRequest, NextResponse } from 'next/server';
import { polar, ORGANIZATION_ID, SUBSCRIPTION_TIERS, SubscriptionTier } from '@/lib/polar';
import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/auth';

export async function POST(request: NextRequest) {
  try {
    const session = await getServerSession(authOptions);
    if (!session?.user?.email) {
      return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
    }

    const { tier, interval } = await request.json() as {
      tier: SubscriptionTier;
      interval: 'month' | 'year';
    };

    const tierConfig = SUBSCRIPTION_TIERS[tier];
    if (!tierConfig) {
      return NextResponse.json({ error: 'Invalid tier' }, { status: 400 });
    }

    const price = interval === 'year' 
      ? tierConfig.priceYearly 
      : tierConfig.priceMonthly;

    // Create checkout session
    const checkout = await polar.checkouts.create({
      productPriceId: `price_${tier}_${interval}`,
      successUrl: `${process.env.NEXT_PUBLIC_APP_URL}/dashboard?subscription=success`,
      customerEmail: session.user.email,
      metadata: {
        userId: session.user.id,
        tier,
        interval,
      },
    });

    return NextResponse.json({ checkoutUrl: checkout.url });
  } catch (error) {
    console.error('Checkout creation failed:', error);
    return NextResponse.json(
      { error: 'Failed to create checkout' },
      { status: 500 }
    );
  }
}
```

## Webhook Handler

Process Polar.sh webhooks for subscription events:

```typescript
// app/api/webhooks/polar/route.ts
import { NextRequest, NextResponse } from 'next/server';
import { Webhooks } from '@polar-sh/sdk/webhooks';
import { db } from '@/lib/db';

const webhooks = new Webhooks({
  webhookSecret: process.env.POLAR_WEBHOOK_SECRET!,
});

export async function POST(request: NextRequest) {
  const payload = await request.text();
  const signature = request.headers.get('polar-signature')!;

  let event;
  try {
    event = webhooks.verify(payload, signature);
  } catch (error) {
    console.error('Webhook verification failed:', error);
    return NextResponse.json({ error: 'Invalid signature' }, { status: 400 });
  }

  try {
    switch (event.type) {
      case 'subscription.created': {
        const subscription = event.data;
        await handleSubscriptionCreated(subscription);
        break;
      }
      case 'subscription.updated': {
        const subscription = event.data;
        await handleSubscriptionUpdated(subscription);
        break;
      }
      case 'subscription.canceled': {
        const subscription = event.data;
        await handleSubscriptionCanceled(subscription);
        break;
      }
      case 'order.created': {
        const order = event.data;
        await handleOrderCreated(order);
        break;
      }
    }

    return NextResponse.json({ received: true });
  } catch (error) {
    console.error('Webhook handler error:', error);
    return NextResponse.json({ error: 'Handler failed' }, { status: 500 });
  }
}

async function handleSubscriptionCreated(subscription: any) {
  const userId = subscription.metadata?.userId;
  if (!userId) return;

  await db.user.update({
    where: { id: userId },
    data: {
      polarSubscriptionId: subscription.id,
      subscriptionTier: subscription.metadata?.tier,
      subscriptionStatus: 'active',
      subscriptionCurrentPeriodEnd: new Date(subscription.currentPeriodEnd),
    },
  });

  // Send welcome email
  await emailService.sendSubscriptionWelcome(
    subscription.customer.email,
    subscription.metadata?.tier
  );
}

async function handleSubscriptionCanceled(subscription: any) {
  const userId = subscription.metadata?.userId;
  if (!userId) return;

  await db.user.update({
    where: { id: userId },
    data: {
      subscriptionStatus: 'canceled',
      subscriptionEndsAt: new Date(subscription.currentPeriodEnd),
    },
  });
}
```

## Digital Products Store

Sell digital products like premium prompts:

```typescript
// lib/products.ts
import { polar, ORGANIZATION_ID } from './polar';

export async function listProducts() {
  const products = await polar.products.list({
    organizationId: ORGANIZATION_ID,
    isArchived: false,
  });

  return products.items.map((product) => ({
    id: product.id,
    name: product.name,
    description: product.description,
    price: product.prices[0]?.priceAmount || 0,
    type: product.type,
    benefits: product.benefits,
  }));
}

export async function createProductCheckout(
  productId: string,
  userEmail: string,
  userId: string
) {
  const checkout = await polar.checkouts.create({
    productId,
    customerEmail: userEmail,
    successUrl: `${process.env.NEXT_PUBLIC_APP_URL}/purchases?success=true`,
    metadata: { userId },
  });

  return checkout;
}

// app/products/page.tsx
import { listProducts } from '@/lib/products';
import { ProductCard } from '@/components/ProductCard';

export default async function ProductsPage() {
  const products = await listProducts();

  return (
    <div className="products-page">
      <h1>Premium Resources</h1>
      <p>Exclusive prompts and workflows for professional developers</p>
      
      <div className="products-grid">
        {products.map((product) => (
          <ProductCard key={product.id} product={product} />
        ))}
      </div>
    </div>
  );
}
```

## Subscriber Benefits Access

Control access to premium content:

```typescript
// lib/access-control.ts
import { db } from './db';
import { cache } from 'react';

export const checkSubscriptionAccess = cache(async (userId: string) => {
  const user = await db.user.findUnique({
    where: { id: userId },
    select: {
      subscriptionTier: true,
      subscriptionStatus: true,
      subscriptionCurrentPeriodEnd: true,
    },
  });

  if (!user) return { hasAccess: false, tier: null };

  const isActive = 
    user.subscriptionStatus === 'active' &&
    user.subscriptionCurrentPeriodEnd &&
    new Date(user.subscriptionCurrentPeriodEnd) > new Date();

  return {
    hasAccess: isActive,
    tier: isActive ? user.subscriptionTier : null,
  };
});

// Higher-order component for protected content
export function withSubscription<T extends { userId: string }>(
  Component: React.ComponentType<T & { subscription: SubscriptionAccess }>,
  requiredTier?: SubscriptionTier
) {
  return async function ProtectedComponent(props: T) {
    const subscription = await checkSubscriptionAccess(props.userId);
    
    if (!subscription.hasAccess) {
      return <UpgradePrompt />;
    }
    
    if (requiredTier && !hasRequiredTier(subscription.tier, requiredTier)) {
      return <TierUpgradePrompt currentTier={subscription.tier} requiredTier={requiredTier} />;
    }

    return <Component {...props} subscription={subscription} />;
  };
}
```

## Best Practices

1. **Verify webhook signatures** to prevent spoofed events
2. **Store subscription state** in your database for offline access checks
3. **Implement grace periods** for subscription renewals
4. **Cache access checks** to reduce database queries
5. **Send confirmation emails** for all subscription changes
6. **Track analytics** on conversion funnels
7. **Offer annual discounts** to improve retention

When to Use This Prompt

This polar prompt is ideal for developers working on:

  • polar applications requiring modern best practices and optimal performance
  • Projects that need production-ready polar code with proper error handling
  • Teams looking to standardize their polar development workflow
  • Developers wanting to learn industry-standard polar patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their polar implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the polar code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this polar prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For polar projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...