pwafire
TypeScript icon, indicating that this package has built-in type declarations

5.1.11 • Public • Published

PWAFire (Progressive Web Apps APIs)

A modern, modular library for building Progressive Web Apps with ease. PWAFire provides a comprehensive set of APIs and utilities to enhance your web applications with PWA capabilities. Built on top of Project Fugu, PWAFire helps bridge the gap between web and native app capabilities.

npm version License: MIT Documentation Downloads

For complete documentation and examples, visit Get Started with PWAFire.

Features

  • Modern, tree-shakeable API design
  • Comprehensive PWA capabilities
  • Zero dependencies
  • TypeScript support
  • Universal browser support
  • Multiple import options (ESM, CJS, CDN)
  • Consistent camelCase naming convention
  • Built-in feature detection
  • Comprehensive documentation
  • Extensive test coverage

Quick Start

Installation

# Using npm
npm install pwafire@latest

# Using yarn
yarn add pwafire@latest

# Using pnpm
pnpm add pwafire@latest

Import Patterns

PWAFire supports two import patterns for optimal flexibility and tree-shaking:

  1. Root Import (Recommended for multiple features):

    import { copyText, webShare } from "pwafire";
  2. Scoped Import (Recommended for single features):

    import { copyText } from "pwafire/clipboard";
    import { webShare } from "pwafire/web-share";

The scoped import pattern is recommended when you only need specific features, as it enables better tree-shaking and smaller bundle sizes.

Basic Usage

// Using root import
import { copyText } from "pwafire";

// Using scoped import (recommended for single features)
import { copyText } from "pwafire/clipboard";

const { ok, message } = await copyText("Text to copy");

CDN Usage

<script type="module">
  // Using root import
  import { copyText } from "https://unpkg.com/pwafire@latest/lib/index.mjs";

  // Using scoped import
  import { copyText } from "https://unpkg.com/pwafire@latest/lib/pwa/clipboard/index.mjs";

  const result = await copyText("Text to copy");
</script>

Error Handling

import { copyText } from "pwafire/clipboard";

const handleCopy = async (text: string) => {
  try {
    const { ok, message } = await copyText(text);
  } catch (error) {
    // Handle error
  }
};

await handleCopy("Hello World");

Feature Detection

// Using root import
import { check } from "pwafire";

// Using scoped import
import { check } from "pwafire/check";

const checkFeatures = async () => {
  const [isShareSupported, isClipboardSupported] = await Promise.all([check.webShare(), check.clipboard()]);
};

await checkFeatures();

Browser Support

All APIs are stable in:

  • Chrome 80+
  • Microsoft Edge
  • Firefox
  • Safari

Check Browser Support for detailed compatibility information.

Testing

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

Contributing

We welcome contributions! Please read our Contributing Guide to get started.

Development Setup

# Clone the repository
git clone https://github.com/pwafire/pwafire.git

# Install dependencies
npm install

# Start development
npm run dev

How to Contribute

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT © PWAFire

Documentation

For detailed documentation and examples, visit Get Started with PWAFire.

Community

  • Twitter - Follow us for updates and announcements

Issues

Found a bug? Please create an issue to help us improve!

Related Projects

  • PWA VS Code - Progressive Web Apps Code Snippets (Including Workbox Support)

Package Sidebar

Install

npm i pwafire

Weekly Downloads

28

Version

5.1.11

License

MIT

Unpacked Size

158 kB

Total Files

122

Last publish

Collaborators

  • mayeedwin