@farmart-tech/brave-firebase-adapter
    Preparing search index...

    @farmart-tech/brave-firebase-adapter

    @farmart-tech/brave-firebase-adapter

    Firebase Firestore adapter for reading Brave Ship feature flags and maintenance windows.

    @farmart-tech/brave-firebase-adapter provides a high-performance implementation for fetching and subscribing to feature flag data directly from Google Cloud Firestore. It handles complex workspace fallback logic and maintains an efficient internal cache.

    • ⚡ Real-time Subscriptions: React to feature flag changes instantly using Firestore onSnapshot.
    • 📦 Smart Caching: Built-in memory cache to minimize Firestore read operations.
    • 🛡️ Workspace Fallbacks: Automatically fall back to 'global' workspace data when workspace-specific flags are missing.
    • 🔍 Prefetching Support: Batch-fetch flags, segments, and conditions for optimal application startup.
    • 📱 Device-Level persistence: Integration with local storage for consistent experience across sessions.
    npm install @farmart-tech/brave-firebase-adapter
    # or
    pnpm add @farmart-tech/brave-firebase-adapter
    • firebase ^11.5.0
    • @farmart-tech/brave-feature-core
    • @farmart-tech/brave-window-core
    import { FeatureFlagReader } from '@farmart-tech/brave-firebase-adapter';
    import { getFirestore } from 'firebase/firestore';

    // 1. Initialize Firestore
    const db = getFirestore(app);

    // 2. Create reader
    const reader = new FeatureFlagReader({
    db,
    workspace: 'production',
    environment: 'production',
    userContext: { userId: 'current-user-id' }
    });

    // 3. Fetch a feature
    const feature = await reader.getFeatureFlag('new_hero_section');

    if (feature && await feature.getIsEnabled()) {
    renderNewHero();
    }
    const unsubscribe = reader.subscribeToFeatureFlags((features) => {
    const isEnabled = features['experimental_feature']?.getIsEnabled();
    updateUI(isEnabled);
    });

    // Later
    unsubscribe();
    import { WindowReader } from '@farmart-tech/brave-firebase-adapter';

    const windowReader = new WindowReader({
    db,
    workspace: 'production'
    });

    const config = await windowReader.getRemoteConfig('dashboard_app');
    if (config?.getIsInMaintenance('web')) {
    showMaintenancePage();
    }

    Comprehensive API documentation is available at: https://fmt-feature-management.web.app/docs/firebase-adapter/

    MIT © FarMart