Polar
Last updated December 18, 2025
Overview
Polar.sh is the default payments provider in the scaffold. It handles subscription management, checkout flows, customer portals, and webhook events for subscription lifecycle changes.
Account Setup
- Go to polar.sh and sign up for an account
- Complete your organization profile
- Connect a payment method (Stripe account) - Polar uses Stripe as the payment processor
- Navigate to your organization dashboard
Create Products
- In your Polar dashboard, go to "Products" → "New Product"
- Create your subscription tiers (e.g., "Starter" and "Professional")
- For each product:
- Set the name, description, and pricing
- Choose billing interval (monthly, yearly, etc.)
- Copy the Product ID (you'll need this)
- Copy the Product Slug (you'll need this too)
- Make note of at least one product ID and slug for your starter tier
API Keys
- Go to "Settings" → "API Keys" in your Polar dashboard
- Click "Generate API Key"
- Name it (e.g., "Production API Key" or "Development")
- Copy the Access Token - this is your
POLAR_ACCESS_TOKEN - Important: Store this securely - you won't be able to see it again after closing the dialog
Webhooks
Webhooks notify your app when subscription events occur (created, canceled, updated, etc.).
Step 1: Generate Webhook Secret
- Go to "Settings" → "Webhooks" in your Polar dashboard
- Click "Add Endpoint" or edit existing endpoint
- Set the endpoint URL:
- Development:
http://localhost:3000/api/webhooks/polar(use ngrok for local testing) - Production:
https://yourdomain.com/api/webhooks/polar
- Development:
- Copy the Webhook Secret - this is your
POLAR_WEBHOOK_SECRET - Select the events you want to receive (recommended: all subscription events)
- Save the endpoint
Environment Variables
Add these variables to your .env.local file:
# Polar.sh API POLAR_ACCESS_TOKEN="your-polar-access-token" # Polar.sh Webhooks POLAR_WEBHOOK_SECRET="your-webhook-secret" # Polar.sh Products (from step 2) NEXT_PUBLIC_STARTER_TIER="your-product-id" NEXT_PUBLIC_STARTER_SLUG="your-product-slug" # Success URL (where users redirect after successful payment) POLAR_SUCCESS_URL="success" NEXT_PUBLIC_APP_URL="http://localhost:3000"
Important:
POLAR_ACCESS_TOKENcomes from "Settings" → "API Keys"POLAR_WEBHOOK_SECRETcomes from "Settings" → "Webhooks"NEXT_PUBLIC_STARTER_TIERis the Product ID from your productNEXT_PUBLIC_STARTER_SLUGis the Product Slug from your productPOLAR_SUCCESS_URLis the relative path where users redirect after checkout
Testing
- Restart your dev server:
npm run dev - Navigate to
/pricingpage - Click "Get Started" on a plan
- Complete the checkout flow (use Stripe test cards)
- Verify webhook events are received (check server logs)
- Check that subscription status updates in your database
Test Cards (Stripe):
- Success:
4242 4242 4242 4242 - Decline:
4000 0000 0000 0002 - Any future expiry date, any 3-digit CVC
Testing Webhooks Locally: Use ngrok to expose your local server:
ngrok http 3000
Then use the ngrok URL in your Polar webhook endpoint configuration.