Import
import { UpgradeNudge } from "@billingos/sdk";
Basic usage
<UpgradeNudge
trigger={nudgeTrigger}
style="banner"
onUpgrade={(priceId) => openCheckout(priceId)}
/>
Displays an upgrade prompt when usage data indicates the user should upgrade. Supports three display styles.
Props
The nudge trigger data, typically from the checkUsage() API response.
type
'usage_threshold' | 'feature_access' | 'time_based' | 'custom'
What triggered the nudge.
Feature key that triggered the nudge.
Usage threshold percentage.
Call-to-action button text
Amount, currency, interval
style
'banner' | 'toast' | 'modal'
default:"'banner'"
Display style:
banner — Top banner, non-intrusive
toast — Bottom-right notification
modal — Centered dialog, more prominent
Auto-dismiss after N milliseconds. 0 means no auto-dismiss.
onUpgrade
(priceId: string) => void
Called when the user clicks the upgrade button.
Called when the user dismisses the nudge.
Example: Auto-check and show nudge
import { UpgradeNudge, useBillingOS } from "@billingos/sdk";
import { useQuery } from "@tanstack/react-query";
function NudgeWrapper() {
const { client } = useBillingOS();
const { data } = useQuery({
queryKey: ["usage-check"],
queryFn: () => client!.checkUsage(),
enabled: !!client,
});
if (!data?.shouldShowNudge || !data.trigger) return null;
return (
<UpgradeNudge
trigger={data.trigger}
style="banner"
onUpgrade={(priceId) => {
router.push(`/pricing?upgrade=${priceId}`);
}}
onDismiss={() => {
// Optionally track dismissal
}}
/>
);
}