This guide takes you from zero to a working feature flag in your React app. By the end, you’ll be toggling features from the Flagmint dashboard in real-time.
Using Vue.js or Node.js? The steps are the same — just swap the SDK. See Vue SDK or Node.js SDK for framework-specific setup.
Add FlagmintProvider to your app’s root layout. This creates a single connection to Flagmint that all your components share.
// app/providers.tsx'use client';import { FlagmintProvider } from 'flagmint-react-sdk/client';export function Providers({ children }: { children: React.ReactNode }) { return ( <FlagmintProvider options={{ apiKey: process.env.NEXT_PUBLIC_FLAGMINT_KEY!, transportMode: 'websocket', }} > {children} </FlagmintProvider> );}// app/layout.tsximport { Providers } from './providers';export default function RootLayout({ children }: { children: React.ReactNode }) { return ( <html> <body> <Providers>{children}</Providers> </body> </html> );}
Place FlagmintProvider as high as possible in your component tree — ideally in the root layout. This avoids reconnecting the WebSocket on every route change.