Skip to content

Commit

Permalink
chore: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
brankoconjic authored Jun 14, 2024
1 parent 94b7e5c commit 80d4357
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

[![NPM version](https://img.shields.io/npm/v/%40lemonsqueezy%2Flemonsqueezy.js?label=&color=%230d9488)](https://www.npmjs.com/package/@lemonsqueezy/lemonsqueezy.js)
[![Functions usage](https://img.shields.io/badge/Wiki-%237c3aed)](https://github.com/lmsqueezy/lemonsqueezy.js/wiki)
[![APIs Count](https://img.shields.io/badge/56_Functions-%232563eb)](https://github.com/lmsqueezy/lemonsqueezy.js/wiki)
[![APIs Count](https://img.shields.io/badge/57_Functions-%232563eb)](https://github.com/lmsqueezy/lemonsqueezy.js/wiki)
[![Weekly downloads](https://img.shields.io/npm/dw/@lemonsqueezy/lemonsqueezy.js)](https://www.npmjs.com/package/@lemonsqueezy/lemonsqueezy.js)
![NPM Downloads](https://img.shields.io/npm/d18m/%40lemonsqueezy%2Flemonsqueezy.js)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Flmsqueezy%2Flemonsqueezy.js.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Flmsqueezy%2Flemonsqueezy.js?ref=badge_shield)

## Introduction

This is the official JavaScript SDK for [Lemon Squeezy](https://lemonsqueezy.com), helping make it easy to incorporate billing into your JavaScript application.
This is the official JavaScript SDK for [Lemon Squeezy](https://lemonsqueezy.com), making it easy to incorporate billing into your JavaScript application.

- Read [API Reference](https://docs.lemonsqueezy.com/api) to understand how the Lemon Squeezy API works.
- Visit [Wiki page](https://github.com/lmsqueezy/lemonsqueezy.js/wiki) for function usage.

## Features

- Type-safe: Written in [TypeScript](https://www.typescriptlang.org/) and documented with [TSDoc](https://github.com/microsoft/tsdoc).
- Tree-shakeable: Use only functions that you need. See [bundle size](#bundle-size).
- Tree-shakeable: Use only the functions you need. See [bundle size](#bundle-size).

## Installation

Expand All @@ -44,9 +44,13 @@ Create a new API key from [Settings > API](https://app.lemonsqueezy.com/settings

Add this API key into your project, for example as `LEMONSQUEEZY_API_KEY` in your `.env` file.

> [!CAUTION]
>
> Do not use this package directly in the browser, as this will expose your API key. This would give anyone full API access to your Lemon Squeezy account and store(s). For more information [see here](https://docs.lemonsqueezy.com/api#authentication).
### Using the API in test mode

You can build and test a full API integration with Lemon Squeezy using test mode.
You can build and test a full API integration with Lemon Squeezy using [Test Mode](https://docs.lemonsqueezy.com/help/getting-started/test-mode).

Any API keys created in test mode will interact with your test mode store data.

Expand All @@ -55,11 +59,22 @@ When you are ready to go live with your integration, make sure to create an API
## Usage

```tsx
lemonSqueezySetup({ apiKey });
import { getAuthenticatedUser, lemonSqueezySetup } from "@lemonsqueezy/lemonsqueezy.js";

const apiKey = import.meta.env.LEMON_SQUEEZY_API_KEY;

lemonSqueezySetup({
apiKey,
onError: (error) => console.error("Error!", error),
});

const { data, error, statusCode } = await getAuthenticatedUser();
const { data, error } = await getAuthenticatedUser();

console.log({ data, error, statusCode });
if (error) {
console.log(error.message);
} else {
console.log(data);
}
```

For more functions usage, see [Wiki](https://github.com/lmsqueezy/lemonsqueezy.js/wiki).
Expand Down Expand Up @@ -132,10 +147,6 @@ For more functions usage, see [Wiki](https://github.com/lmsqueezy/lemonsqueezy.j

</details>

## Notes

Do not use this package directly in the browser, as this will expose your API key. This would give anyone full API access to your Lemon Squeezy account and store(s). For more information [see more](https://docs.lemonsqueezy.com/api#authentication).

## Contributing

See the [Contributing Guide](https://github.com/lmsqueezy/lemonsqueezy.js/blob/main/CONTRIBUTING.md).
Expand Down

0 comments on commit 80d4357

Please sign in to comment.