React Router 7 with Vite
Project Overview
Setup and Configuration
1. Flagship Provider Setup
// helpers/FsProvider.tsx
import FlagshipProvider, {
LogLevel,
type VisitorData,
} from "@flagship.io/react-sdk";
import { Loader } from "../components/Loader";
export function FsProvider({
children,
visitorData
}: {
children: React.ReactNode;
visitorData?: VisitorData;
}) {
return (
<FlagshipProvider
envId={import.meta.env.VITE_ENV_ID} // Environment ID from Flagship
apiKey={import.meta.env.VITE_API_KEY} // API Key from Flagship
logLevel={LogLevel.DEBUG}
visitorData={visitorData || null} // visitor data to pass
loadingComponent={<Loader />} // Optional Loading component while flags are being fetched
>
{children}
</FlagshipProvider>
);
}2. Application Structure
3. Layout Component
4. Navigation Component
Using Flagship Flags
Option 1: Use the useFsFlag Hook Directly
useFsFlag Hook DirectlyOption 2: Create Reusable Flag Components
Sending Analytics Hits
Handling Loading States
Environment Configuration
Running the Application
Additional Considerations
Last updated
Was this helpful?

