Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hamlim/better-beacon

A better version of navigator.sendBeacon!
https://github.com/hamlim/better-beacon

navigator sendbeacon

Last synced: 24 days ago
JSON representation

A better version of navigator.sendBeacon!

Awesome Lists containing this project

README

        

# Better (send)Beacon

A better version of `navigator.sendBeacon`, that doesn't break when you try to queue too many events!1

## Installation:

```sh
bun add better-beacon
```

## Usage:

```tsx
import BetterBeacon from "better-beacon";

let bbeacon = new BetterBeacon({
autoTransformJSON: true,
});

// Works just like `navigator.sendBeacon`!
bbeacon.send("/path", "true");

// Automatically converts objects to Blobs under the hood
bbeacon.send("/path", { data: true });
```

## Context:

You might be wondering, why does this library exist? Well fortunately for you, I wrote up a short blog post about it available here: [Building Better Beacon](https://matthamlin.me/2024/january/building-better-beacon)

## Contributing:

### `build`

```sh
bun run build
```

### `test`

```sh
bun test
```

### Tools:

- Typescript
- SWC
- Bun