Skip to content

lemonSqueezySetup

Branko Conjic edited this page Feb 8, 2024 · 2 revisions

lemonSqueezySetup

Initialization configuration.

Only three functions (activateLicense,validateLicense,deactivateLicense) operate without requiring an API key. To use other functions, you must employ lemonSqueezySetup to configure the apiKey before utilization.

Create a new API key: https://app.lemonsqueezy.com/settings/api.

Usage

Configure the API Key

import { lemonSqueezySetup } from '@lemonsqueezy/lemonsqueezy.js';

lemonSqueezySetup({
	apiKey: 'Your Lemon Squeezy API Key',
});

Configure the global fetch response error handling method:

import { lemonSqueezySetup } from '@lemonsqueezy/lemonsqueezy.js';

lemonSqueezySetup({
	apiKey: import.meta.env.LEMON_SQUEEZY_API_KEY,
	onError(error) {
		console.log(error);
	},
});

Type Declarations

type Config = {
	/**
	 * `Lemon Squeezy` API Key
	 */
	apiKey?: string;
	/**
	 * Fires after a fetch response error
	 *
	 * @param error Error
	 * @returns void
	 */
	onError?: (error: Error) => void;
};

/**
 * Lemon squeezy setup.
 *
 * @param config The config.
 * @returns User configuration.
 */
declare function lemonSqueezySetup(config: Config): Config;

Source

Source ~ Type ~ Test

Clone this wiki locally