Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

538 B
Raw Blame
import { useMemo } from 'react'

import { isSelfhosted } from '~/lib/constants'
import type { PlanFeatureCode } from '~/lib/pricing/features'
import { useCurrentProject } from '~/providers/CurrentProjectProvider'

export const useProjectFeatureAccess = (feature: PlanFeatureCode) => {
  const { project } = useCurrentProject()

  return useMemo(() => {
    const isOwner = project?.role === 'owner'

    return {
      hasAccess: isSelfhosted || project?.featureAccess?.[feature] === true,
      isOwner,
    }
  }, [feature, project])
}