MCPcopy Create free account
hub / github.com/awkweb/react-supabase / useSubscription

Function useSubscription

src/hooks/realtime/use-subscription.ts:14–31  ·  view source on GitHub ↗
(
    callback: (payload: SupabaseRealtimePayload<Data>) => void,
    config: UseSubscriptionConfig = { event: '*', table: '*' },
)

Source from the content-addressed store, hash-verified

12}
13
14export function useSubscription<Data = any>(
15 callback: (payload: SupabaseRealtimePayload<Data>) => void,
16 config: UseSubscriptionConfig = { event: '*', table: '*' },
17) {
18 const client = useClient()
19
20 /* eslint-disable react-hooks/exhaustive-deps */
21 useEffect(() => {
22 const subscription = client
23 .from<Data>(config.table ?? '*')
24 .on(config.event ?? '*', callback)
25 .subscribe()
26 return () => {
27 subscription.unsubscribe()
28 }
29 }, [])
30 /* eslint-enable react-hooks/exhaustive-deps */
31}

Callers 2

useRealtimeFunction · 0.90

Calls 1

useClientFunction · 0.90

Tested by

no test coverage detected