Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Helicone Helicone UseHasAccess

From Leeroopedia
Revision as of 12:58, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Helicone_Helicone_UseHasAccess.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Feature Access, Authorization
Last Updated 2026-02-14 06:32 GMT

Overview

A core React hook that determines whether the current user has access to a specific feature based on their organization's subscription tier and addon status.

Description

The useHasAccess hook is the central access control primitive used throughout the Helicone dashboard UI. It reads the organization's subscription tier and Stripe metadata from the useOrg context and computes a memoized boolean indicating feature access.

Decision logic (evaluated in order):

  1. Non-free features -- If the feature is listed in NON_FREE_FEATURES, access is granted to any tier except "free".
  1. Full-access tiers -- Tiers growth, enterprise, pro, demo, team-20250130, team-20251210, and pro-20251210 get automatic access to all features.
  1. Grandfathered legacy pro -- The pro-20240913 tier gets access to evals and experiments if they have the prompts addon active (a grandfathering policy for early adopters).
  1. Legacy pro with addons -- Tiers pro-20240913 and pro-20250202 require explicit addon flags in stripe_metadata.addons for addon features (evals, experiments, prompts).
  1. Free tier -- Returns false for all addon features.

The result is memoized with useMemo, re-computing only when the organization tier, Stripe metadata, or feature ID changes.

Usage

Use this hook in any component that needs to conditionally render or enable features based on the user's subscription. It is the building block for higher-level hooks like useFeatureLimit and is called directly for simple show/hide access checks.

Code Reference

Source Location

Signature

export const useHasAccess = (feature: FeatureId) => boolean;

Import

import { useHasAccess } from "@/hooks/useHasAccess";

I/O Contract

Input

Parameter Type Description
feature FeatureId The feature identifier to check access for (e.g., "prompts", "experiments", "evals")

Output

Returns Type Description
(result) boolean true if the current organization has access to the specified feature

Access Matrix

Tier Non-free Features Addon Features (prompts, experiments, evals)
free No No
growth Yes Yes (all)
enterprise Yes Yes (all)
pro Yes Yes (all)
demo Yes Yes (all)
team-20250130 Yes Yes (all)
team-20251210 Yes Yes (all)
pro-20251210 Yes Yes (all)
pro-20240913 Yes Requires addon; evals/experiments grandfathered if prompts addon active
pro-20250202 Yes Requires explicit addon in stripe_metadata

Usage Examples

import { useHasAccess } from "@/hooks/useHasAccess";

function ExperimentsPage() {
  const hasExperimentAccess = useHasAccess("experiments");

  if (!hasExperimentAccess) {
    return <UpgradePrompt feature="experiments" />;
  }

  return <ExperimentsDashboard />;
}

// Conditionally render a feature button
function FeatureButton({ feature, children }) {
  const hasAccess = useHasAccess(feature);

  return (
    <button disabled={!hasAccess}>
      {children}
      {!hasAccess && <span className="text-muted-foreground"> (Pro)</span>}
    </button>
  );
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment