Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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!
- Host: GitHub
- URL: https://github.com/hamlim/better-beacon
- Owner: hamlim
- Created: 2024-01-12T22:01:09.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-02-17T22:10:31.000Z (9 months ago)
- Last Synced: 2024-10-22T23:14:00.931Z (28 days ago)
- Topics: navigator, sendbeacon
- Language: TypeScript
- Homepage: https://matthamlin.me/2024/january/building-better-beacon
- Size: 71.3 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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