Implementation:Helicone Helicone UseHasAccess
| 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):
- Non-free features -- If the feature is listed in
NON_FREE_FEATURES, access is granted to any tier except"free".
- Full-access tiers -- Tiers
growth,enterprise,pro,demo,team-20250130,team-20251210, andpro-20251210get automatic access to all features.
- Grandfathered legacy pro -- The
pro-20240913tier gets access toevalsandexperimentsif they have thepromptsaddon active (a grandfathering policy for early adopters).
- Legacy pro with addons -- Tiers
pro-20240913andpro-20250202require explicit addon flags instripe_metadata.addonsfor addon features (evals, experiments, prompts).
- Free tier -- Returns
falsefor 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
- Repository: Helicone
- File: web/hooks/useHasAccess.ts
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>
);
}