Setting Up LemonSqueezy Integration
Follow these steps to integrate LemonSqueezy for handling subscriptions, one-time payments, and subscription plans in your application.
Step 1: Create a LemonSqueezy Account
- Go to the LemonSqueezy website and sign up for an account.
- Once logged in, set up your store and take note of the Store ID.
Step 2: Generate API Key
- Navigate to the API section in your LemonSqueezy dashboard.
- Create an API key and copy it. This key is required for server-side interactions.
Step 3: Add Environment Variables
- Open your
.env.local
file. - Add the following environment variables:
LEMONSQUEEZY_STORE_ID= YOUR_STORE_ID LEMONSQUEEZY_API_KEY= YOUR_API_KEY LEMONSQUEEZY_WEBHOOK_SECRET= YOUR_WEBHOOK_SECRET
Step 4: Set Up Product and Variant IDs
- In your LemonSqueezy store, create your products (subscription or single payment).
- Under each product, copy get the Variant ID.
- Update the
lib/subscriptions.ts
file with your product Variant IDs.
export const basicPlan: ISubscriptionPlan = {
name: 'Basic Plan',
type: 'basic',
// Replace these IDs with the actual variant IDs from LemonSqueezy
monthlyPlanId: '269320',
yearlyPlanId: '269321',
};
export const proPlan: ISubscriptionPlan = {
name: 'Pro Plan',
type: 'pro',
// Replace these IDs with the actual variant IDs from LemonSqueezy
monthlyPlanId: '269322',
yearlyPlanId: '269323',
};