This repository has no description
1'use client';
2
3import { useQuery } from '@tanstack/react-query';
4
5interface FeatureFlags {
6 cardSearch: boolean;
7 urlTypeFilter: boolean;
8 leafletMentions: boolean;
9 animatedLandingTitle: boolean;
10 openCollections: boolean;
11 following: boolean;
12 connections: boolean;
13 graphView: boolean;
14}
15
16async function fetchFeatureFlags(): Promise<FeatureFlags> {
17 const response = await fetch('/api/feature-flags');
18 if (!response.ok) {
19 throw new Error('Failed to fetch feature flags');
20 }
21 return response.json();
22}
23
24export function useFeatureFlags() {
25 return useQuery({
26 queryKey: ['feature-flags'],
27 queryFn: fetchFeatureFlags,
28 staleTime: 5 * 60 * 1000, // 5 minutes
29 gcTime: 10 * 60 * 1000, // 10 minutes
30 });
31}