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.
onSnapshot.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-coreimport { 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