Barazo default frontend barazo.forum
at main 23 lines 604 B view raw
1/** 2 * Hook to access plugin context. 3 * Returns a safe default when used outside PluginProvider (SSR, tests). 4 */ 5 6'use client' 7 8import { useContext } from 'react' 9import { PluginContext } from '@/context/plugin-context' 10import type { PluginContextValue } from '@/context/plugin-context' 11 12const defaultContext: PluginContextValue = { 13 plugins: [], 14 isPluginEnabled: () => false, 15 getPluginSettings: () => null, 16 isLoading: false, 17 refreshPlugins: async () => {}, 18} 19 20export function usePlugins(): PluginContextValue { 21 const context = useContext(PluginContext) 22 return context ?? defaultContext 23}