LemonSqueezy
Lemon Squeezy is the all-in-one platform for running your SaaS business. Payments, subscriptions, global tax compliance, fraud prevention, multi-currency support, failed payment recovery, PayPal integration and more.
Getting started
Create an account
To get started with Lemonsqueezy, you need to create an account. Then you can set up your store.
Create API key
After setting up your account and store, head over to Settings > API and clicking on the button to create a new API key.
Take note of the key and add it to your .env
file as LEMONSQUEEZY_API_KEY
.
LEMONSQUEEZY_API_KEY=
Create Products
To create a new product, go to the Products page and click the Plus button.
For this to work out properly you need to create a product as Subscription. Then you can use variants to specify different plans. You can create as many variants as you want and add different periods of billing, specify if there is a trial, etc.
Create Webhook
Webhooks are a way for an app to provide other applications with real-time information. A webhook delivers data to other applications as it happens, meaning you get data immediately.
SveltePak includes a webhook that you can use to listen to events from Lemonsqueezy.
To configure a new webhook, go to the Webhooks page and click the Plus button.
When asked for a secret, you can generate a new one using the following command:
openssl rand -base64 24
Copy the generated string and paste it into the secret field as well as your .env
LEMONSQUEEZY_WEBHOOK_SECRET=your-signing-secret
Then select all events and click on the Save webhook button.
Local development
Ngrok offers a convenient solution for local development. It allows you to expose a local server to the internet, enabling Lemonsqueezy to send webhooks to your local development environment.
To use ngrok, create an account and proceed with official guide.
Then you can run the following command to expose your local server:
ngrok http http://localhost:5173
Once it’s running, you will get a public URL that you can use to set up your webhook.
You just need to use that URL and append /api/webhooks/lmsqueezy
to set up the webhook.
For instance, the webhook URL might look like https://something.ngrok-free.app/api/webhooks/lmsqueezy
Just put this on the Lemonsqueezy webhook URL and you are good to go.
Environment variables
LEMONSQUEEZY_API_KEY=""
LEMONSQUEEZY_STORE_ID=""
LEMONSQUEEZY_WEBHOOK_SECRET=""
LEMONSQUEEZY_API_KEY
- Your Lemonsqueezy API key can be found at https://app.lemonsqueezy.com/settings/apiLEMONSQUEEZY_STORE_ID
- Your Lemonsqueezy store ID can be found at https://app.lemonsqueezy.com/settings/storesLEMONSQUEEZY_WEBHOOK_SECRET
- Your Lemonsqueezy webhook secret can be found at https://app.lemonsqueezy.com/settings/webhooks