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

    @farmart-tech/brave-react-adapter

    @farmart-tech/brave-react-adapter

    React components and hooks for seamless Brave Ship feature flag integration.

    @farmart-tech/brave-react-adapter provides a set of React contexts and hooks to easily consume feature flags in any React application.

    • ⚛️ Hooks-first: Modern hooks like useFeatureEnabled for clean integration.
    • 🖼️ UI Components: Declarative FeatureFlagGate and FeatureVariant components.
    • 🛠️ Context Providers: Dedicated providers for both reading (client) and writing (admin) flags.
    • 🔄 Real-time Updates: Automatically re-renders when feature flag configurations change in Firestore.
    • ⚡ Persisted Startup Values: Reuses context-scoped, last-known evaluations on the first render while revalidating them in the background.
    • 🧩 Type-Safe: Full TypeScript support for feature names and evaluation results.
    npm install @farmart-tech/brave-react-adapter
    # or
    pnpm add @farmart-tech/brave-react-adapter
    • react >=18.0.0
    • firebase ^11.5.0
    • @farmart-tech/brave-admin-sdk (provides core types)
    import { FeatureReaderProvider } from '@farmart-tech/brave-react-adapter';
    import { getFirestore } from 'firebase/firestore';

    const db = getFirestore(app);

    function Root() {
    return (
    <FeatureReaderProvider
    workspace="production"
    db={db}
    userContext={{ userId: 'user-123' }}
    >
    <App />
    </FeatureReaderProvider>
    );
    }
    import { useFeatureEnabled } from '@farmart-tech/brave-react-adapter';

    function Dashboard() {
    const isEnabled = useFeatureEnabled('new_analytics_dashboard');

    if (isEnabled === null) return <Loading />;
    return isEnabled ? <NewDashboard /> : <StandardDashboard />;
    }

    By default, resolved evaluations are stored in local storage for seven days. The cache key includes the workspace, environment, and user context, and every value is revalidated immediately. Applications that must fail closed on every startup can disable this behavior:

    <FeatureReaderProvider
    featureReaderConfig={config}
    featureEvaluationCache={{ enabled: false }}
    >
    <App />
    </FeatureReaderProvider>
    import { FeatureFlagGate } from '@farmart-tech/brave-react-adapter';

    function ProfilePage() {
    return (
    <FeatureFlagGate
    flag="edit_profile_v2"
    fallback={<SimpleProfile />}
    >
    <AdvancedProfileEditor />
    </FeatureFlagGate>
    );
    }

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

    MIT © FarMart