{"id":25651159,"url":"https://github.com/nassiry/fanosjs","last_synced_at":"2026-02-27T12:14:54.790Z","repository":{"id":278130711,"uuid":"934642893","full_name":"nassiry/fanosjs","owner":"nassiry","description":"Fanos is a lightweight JavaScript promise-based library that simplifies sending asynchronous requests using the Beacon API.","archived":false,"fork":false,"pushed_at":"2025-02-23T04:24:24.000Z","size":119,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T01:22:35.495Z","etag":null,"topics":["asynchronous","asynchronous-requests","beacon","non-blocking","requests"],"latest_commit_sha":null,"homepage":"https://github.com/nassiry/fanosjs","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nassiry.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-18T07:05:26.000Z","updated_at":"2025-02-23T04:24:28.000Z","dependencies_parsed_at":"2025-02-18T07:15:22.852Z","dependency_job_id":"89336def-ed78-48b3-8083-b2033a24bbed","html_url":"https://github.com/nassiry/fanosjs","commit_stats":null,"previous_names":["nassiry/fanosjs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nassiry%2Ffanosjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nassiry%2Ffanosjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nassiry%2Ffanosjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nassiry%2Ffanosjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nassiry","download_url":"https://codeload.github.com/nassiry/fanosjs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631686,"owners_count":21136562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asynchronous","asynchronous-requests","beacon","non-blocking","requests"],"created_at":"2025-02-23T16:18:56.886Z","updated_at":"2026-02-27T12:14:49.701Z","avatar_url":"https://github.com/nassiry.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# Fanos 🏮\n\n![Release](https://github.com/nassiry/fanosjs/actions/workflows/release.yml/badge.svg)\n![npm version](https://img.shields.io/npm/v/fanos.svg)\n![Total Downloads](https://img.shields.io/npm/dt/fanos.svg)\n![License](https://img.shields.io/npm/l/fanos.svg)\n\n\u003c/div\u003e\n\n**Fanos** is a lightweight JavaScript `promise-based` library that simplifies sending asynchronous requests using the [Beacon API](https://w3c.github.io/beacon/). It ensures reliable, non-blocking transmission of data to a server, making it ideal for scenarios like analytics, logging, and tracking user interactions. However, it does **but not guaranteed if the browser is closed suddenly**.\n\nTo improve reliability, **Fanos** includes an **optional fallback mechanism using `Fetch`** and supports **automatic retrying of failed requests**. This ensures that your data is transmitted reliably, even in challenging network conditions.\n\n\n## Table of Contents\n\n1. [Features](#features)\n2. [Installation](#1-installation)\n    - [Load From Path](#browser)\n    - [CDN](#cdn)\n    - [ES Modules](#es-modules)\n3. [Quickstart](#2-quickstart)\n   - [Instance-Based Approach](#instance-based-approach)\n    - [Static Method (Global Configuration)](#static-method-global-configuration)\n    - [Flushing the Queue Manually](#flushing-the-queue-manually)\n    - [Destroying the Instance](#destroying-the-instance)\n4. [Important Notes](#3-important-notes)\n5. [Next Steps](#4-next-steps)\n6. [Browser \u0026 Node.js Compatibility](#browser--nodejs-compatibility)\n7. [Contributions](#contributions)\n8. [Changelog](#changelog)\n9. [License](#license)\n\n## Features\n\n- ⏳ **Asynchronous request sending**: Uses the `Beacon API` for non-blocking requests.\n- 🔄 **Optional Fetch fallback**: Enables `Fetch` as a backup if `sendBeacon` fails.\n- 🔁 **Automatic retry**: Stores failed requests in `localStorage` and retries them.\n- 🔄 **Multiple payload formats**: Supports `JSON`, `FormData`, `URL-encoded data`, and `Blobs`.\n- 🧑‍💻 **Custom headers**: Allows adding `headers` for requests.\n- 🐞 **Debug mode**: Logs internal operations for troubleshooting.\n\n## 1. Installation\n\nYou can include **Fanos** in your project via a script tag or install it using `npm`:\n\n```bash\nnpm install fanos\n```\n\n#### Load From Path\n\nInclude the library directly in your HTML:\n\n```html\n\u003cscript src=\"path/to/fanos.umd.min.js\"\u003e\u003c/script\u003e\n```\n#### CDN\n\nUse the library via a CDN:\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/fanos@latest/dist/fanos.umd.min.js\"\u003e\u003c/script\u003e\n```\n\n#### ES Modules\n\nImport the library in your JavaScript project:\n\n```javascript\nimport Fanos from 'dist/fanos.esm'\n```\n\n## 2. Quickstart\n\nHere’s how to get started with **Fanos** in just a few lines of code:\n\n- ### Instance-Based Approach\n\n```javascript\nconst fanos = new Fanos({\n   url: 'https://example.com/api/log',\n});\n\nconst payload = {\n   userId: 123,\n   action: 'login',\n   details: { browser: 'Chrome', os: 'Windows' },\n};\n\nfanos.send(payload)\n   .then(() =\u003e console.log('Sent successfully'))\n   .catch(err =\u003e console.error('Failed to send:', err));\n```\n\n- ### Static Method (Global Configuration)\n\n```javascript\nFanos.configure({\n    url: 'https://example.com/api/log',\n    debug: true,\n});\n\nFanos.send(payload)\n    .then(() =\u003e console.log('Sent successfully'))\n    .catch(err =\u003e console.error('Failed to send:', err));\n```\n- ### Flushing the Queue Manually\n\nThe `flush` method sends all queued requests immediately.\n\n```javascript\nfanos.flush()\n```\n\n- ### Destroying the Instance\n\nThe `destroy` method cleans up resources and stops retries:\n\n```javascript\nfanos.destroy()\n```\n\n## 3. Important Notes\n\n- **Beacon API Dependency**: Fanos relies on the [Beacon API](https://w3c.github.io/beacon/), to send data asynchronously to the server. Note that the Beacon API is specifically designed for sending data and **does not support receiving responses** from the server. For older browsers that do not support the Beacon API, you can enable the `fallbackToFetch` option to use `Fetch` as a fallback mechanism.\n- **Node.js Compatibility**: Fanos is specifically designed for browser environments and is **not compatible with Node.js**. Ensure it is used in client-side applications only.\n- **Debugging**: To assist with troubleshooting, you can enable the `debug` option. This will log internal operations and provide insights into the library's behavior during execution.\n\n## 4. Next Steps\n\n- Explore the full list of [Configuration Options](/docs/configuration.md).\n- Check out more [examples](/examples/index.md) for advanced usage.\n- Refer to the detailed [API documentation](/docs/api.md) for all available methods and properties.\n\n## Browser \u0026 Node.js Compatibility\n\n| Browser/Environment | Support |\n|---------------------|---------|\n| Chrome              | Latest ✔ |\n| Firefox             | Latest ✔ |\n| Safari              | Latest ✔ |\n| Opera               | Latest ✔ |\n| Edge                | Latest ✔ |\n| Node.js             | No ❌   |\n\n\n## Contributions\n\nWe welcome contributions! Please read the [Contributions Guid](CONTRIBUTIONS.md) to learn how to contribute.\n\n## Changelog\n\nSee [Changelog](CHANGELOG.md) for release details.\n\n## License\n\nThis package is open-source software licensed under the [MIT license](LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnassiry%2Ffanosjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnassiry%2Ffanosjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnassiry%2Ffanosjs/lists"}