2024-08-27 16:49:43 +02:00
|
|
|
import { useFeatureFlagsStore } from '~/stores/featureFlags'
|
|
|
|
|
|
2025-05-27 17:44:42 +02:00
|
|
|
export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
|
|
// Get the pinia instance for SSR compatibility
|
|
|
|
|
const { $pinia } = nuxtApp
|
2024-08-27 16:49:43 +02:00
|
|
|
|
2025-05-27 17:44:42 +02:00
|
|
|
try {
|
|
|
|
|
// Pass pinia instance for SSR compatibility
|
|
|
|
|
const featureFlagsStore = useFeatureFlagsStore($pinia)
|
|
|
|
|
|
|
|
|
|
// Fetch flags during SSR to prevent hydration mismatches
|
|
|
|
|
if (!featureFlagsStore.isLoaded) {
|
|
|
|
|
await featureFlagsStore.fetchFlags()
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Feature flags plugin failed:', error)
|
|
|
|
|
}
|
2024-08-27 16:49:43 +02:00
|
|
|
})
|