npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@aisahub/app-builder-sdk

v1.0.5

Published

WebView to Flutter communication bridge SDK for App Builder - Access native device capabilities from web applications

Readme

@aisahub/app-builder-sdk

WebView-to-Flutter communication bridge SDK that enables seamless integration between web applications and native Flutter functionality.

npm version License: MIT

Features

Native Integration - Access device capabilities like push notifications, secure storage, and location services 🔄 Bidirectional Communication - JavaScript-to-Flutter bridge via WebView channels 🌐 Graceful Degradation - Automatic fallback to web APIs when running in browsers 📘 TypeScript Support - Full type definitions included ⚛️ React Hooks - Pre-built hooks for React/Next.js applications 🪶 Zero Dependencies - Lightweight vanilla JavaScript core

Installation

npm install @aisahub/app-builder-sdk

or

yarn add @aisahub/app-builder-sdk

Quick Start

Vanilla JavaScript / HTML

Include the SDK in your HTML:

<script src="node_modules/@aisahub/app-builder-sdk/dist/app-builder-bridge.min.js"></script>
<script>
  if (AppBridge.isInApp()) {
    console.log('Running in app environment');

    AppBridge.generateFcmToken((result) => {
      if (result.success) {
        console.log('FCM Token:', result.token);
      }
    });
  }
</script>

ES Modules / TypeScript

import '@aisahub/app-builder-sdk';

// AppBridge is now available globally
if (window.AppBridge.isInApp()) {
  window.AppBridge.generateFcmToken((result) => {
    console.log('Token:', result.token);
  });
}

React / Next.js

import { useAppBridge, useGenerateFcmToken } from '@aisahub/app-builder-sdk/hooks';

export default function MyComponent() {
  const { isInApp, bridge } = useAppBridge();
  const { generateToken, token, loading } = useGenerateFcmToken();

  return (
    <div>
      <p>Environment: {isInApp ? 'App' : 'Web Browser'}</p>

      <button onClick={generateToken} disabled={loading}>
        {loading ? 'Generating...' : 'Get FCM Token'}
      </button>

      {token && <p>Token: {token}</p>}
    </div>
  );
}

Core API

Environment Detection

AppBridge.isInApp()     // Returns true if running in app environment (native or PWA)
AppBridge.isNativeApp() // Returns true if running in Flutter WebView
AppBridge.isPWA()       // Returns true if running in PWA iframe

Push Notifications

AppBridge.generateFcmToken((result) => {
  if (result.success) {
    console.log('Token:', result.token);
  }
});

Secure Storage

// Save
AppBridge.saveSecure('auth_token', 'xyz123', (result) => {
  console.log('Saved:', result.success);
});

// Get
AppBridge.getSecure('auth_token', (result) => {
  console.log('Value:', result.value);
});

// Delete
AppBridge.deleteSecure('auth_token', (result) => {
  console.log('Deleted:', result.success);
});

Device Information

AppBridge.getDeviceInfo((info) => {
  console.log(info);
  // { model: "Pixel 6", manufacturer: "Google", osVersion: "13", platform: "android" }
});

AppBridge.getAppVersion((info) => {
  console.log(info);
  // { version: "1.2.3", buildNumber: "42" }
});

Location Services

// Request permission
AppBridge.requestLocationPermission((result) => {
  if (result.granted) {
    // Get location
    AppBridge.getCurrentLocation((location) => {
      console.log(location.latitude, location.longitude);
    });
  }
});

User Interactions

// Toast notification
AppBridge.showToast('Settings saved!', 'short');

// Vibration
AppBridge.vibrate(100);

// Share dialog
AppBridge.share('Check this out!', 'https://example.com', (result) => {
  console.log('Shared:', result.success);
});

// Open external URL
AppBridge.openExternalUrl('https://example.com');

// Badge count
AppBridge.setBadgeCount(5);

Authentication

AppBridge.logout((result) => {
  if (result.success) {
    window.location.href = '/login';
  }
});

React Hooks

useAppBridge()

Initialize and access the AppBridge instance:

import { useAppBridge } from '@aisahub/app-builder-sdk/hooks';

const { bridge, isReady, isInApp, isNativeApp, isPWA } = useAppBridge();

useGenerateFcmToken()

Manage FCM token generation with loading states:

import { useGenerateFcmToken } from '@aisahub/app-builder-sdk/hooks';

const { generateToken, token, loading, error } = useGenerateFcmToken();

useDeviceInfo()

Fetch device information:

import { useDeviceInfo } from '@aisahub/app-builder-sdk/hooks';

const { deviceInfo, loading } = useDeviceInfo();

useAppVersion()

Get app version information:

import { useAppVersion } from '@aisahub/app-builder-sdk/hooks';

const { version, loading } = useAppVersion();

useSecureStorage()

Promise-based secure storage operations:

import { useSecureStorage } from '@aisahub/app-builder-sdk/hooks';

const { saveSecure, getSecure, deleteSecure } = useSecureStorage();

// Usage
const saved = await saveSecure('key', 'value');
const value = await getSecure('key');
const deleted = await deleteSecure('key');

TypeScript Support

The SDK includes full TypeScript definitions:

import type {
  AppBridgeAPI,
  FcmTokenResult,
  DeviceInfo,
  LocationResult
} from '@aisahub/app-builder-sdk';

declare global {
  interface Window {
    AppBridge: AppBridgeAPI;
  }
}

Platform Support

  • iOS (via Flutter WebView)
  • Android (via Flutter WebView)
  • Web Browsers (with graceful fallback to web APIs)

Documentation

📚 Complete Documentation

Examples

Authentication Flow

async function loginUser(email, password) {
  // Authenticate with backend
  const response = await fetch('/api/login', {
    method: 'POST',
    body: JSON.stringify({ email, password })
  });

  const { authToken } = await response.json();

  // Save token securely
  AppBridge.saveSecure('auth_token', authToken, (result) => {
    if (result.success) {
      // Get FCM token for push notifications
      AppBridge.generateFcmToken((fcmResult) => {
        if (fcmResult.success) {
          registerDeviceWithBackend(fcmResult.token);
        }
      });

      AppBridge.showToast('Login successful!');
      window.location.href = '/dashboard';
    }
  });
}

Location-Based Features

function findNearbyStores() {
  AppBridge.requestLocationPermission((permissionResult) => {
    if (permissionResult.granted) {
      AppBridge.getCurrentLocation((location) => {
        if (location.latitude) {
          fetch(`/api/stores/nearby?lat=${location.latitude}&lng=${location.longitude}`)
            .then(res => res.json())
            .then(stores => {
              AppBridge.showToast(`Found ${stores.length} stores nearby`);
            });
        }
      });
    }
  });
}

Security

  • 🔒 Secure Storage: Uses iOS Keychain and Android EncryptedSharedPreferences
  • 🔐 HTTPS Only: Always serve your app over HTTPS
  • Input Validation: All inputs are validated before processing

Contributing

Contributions are welcome! Please read our Contributing Guide for details.

License

MIT © AISA Hub

Support


Made with ❤️ by AISA Hub