Replace your hardcoded feature flags with real, controllable ones
npm install @flagswift/react-client
// app/layout.tsx
import { FlagProvider } from '@flagswift/react-client';
export default function Layout({ children }) {
return (
<FlagProvider
apiKey="your-api-key"
environment="production"
>
{children}
</FlagProvider>
);
}
// Replace your old code
const showAbc = useFlag('abc-application');
if (showAbc) {
return <AbcApplication />;
}
return <ComingSoon />;
const params = new URLSearchParams(window.location.search);
const showAbcApplicationBeta = params.get('showAbcApplicationBeta');
export const mockFeatureFlags = [
{
flagKey: 'abc-application',
user: { id: 'user-222', attributes: { organization: 'sea' } },
parsed: { showBeta: showAbcApplicationBeta === 'true' },
provider: 'Launchy', // Not actually Launchy!
}
];
const isAbcEnabled = useFeatureFlag(mockFeatureFlags, FeatureFlagKeys.ABC_APPLICATION);
import { useFlag } from '@flagswift/react-client';
function ABCV1Module() {
const isAbcEnabled = useFlag('abc-application');
return (
<Box maxWidth="100vw">
<Switch>
<Route path="/abc-v1/applications">
<AbcApplication />
</Route>
<Redirect to={isAbcEnabled ? '/abc-v1/applications' : '/abc-v1/all'} />
</Switch>
</Box>
);
}
// Topbar becomes super clean
const Topbar = () => {
const isAbcEnabled = useFlag('abc-application');
const tabs = [
{ url: '/abc-v1/applications', text: 'Applications', show: isAbcEnabled },
{ url: '/abc-v1/all', text: 'All Abc', show: true }
];
return (
<Box>
{tabs.filter(tab => tab.show).map(tab => (
<TabLink key={tab.url} to={tab.url}>{tab.text}</TabLink>
))}
</Box>
);
};
New flags are ON by default. Perfect for local testing.
ENVIRONMENT=development
Test with real data before production release.
ENVIRONMENT=staging
Safe by default. Toggle when ready to launch.
ENVIRONMENT=production
Need to work on a feature that's disabled in production? Here are your options:
Set your local environment to development mode
NEXT_PUBLIC_ENVIRONMENT=development
Override specific flags in browser console
flagClient.setLocalOverride('abc-app', true)
useFlag('new-feature')