The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
'use client'
import { debounce } from 'lodash'
import { useEffect, useMemo, useRef } from 'react'
export const useDebounce = (callback: () => void, delay: number = 1000) => {
const ref = useRef<any | null>(null)
useEffect(() => {
ref.current = callback
}, [callback])
const debouncedCallback = useMemo(() => {
const func = () => {
ref.current?.()
}
return debounce(func, delay)
}, [])
return debouncedCallback
}