Welcome {customer.name}!
*Messages: {customer.features?.messages?.balance}
* {#if !canUpload} * * {/if} * {/if} * ``` * * @example * ```svelte * * * * * * ``` * * @example * ```svelte * * * * * * * * * {#if customer?.features?.messages} *Usage: {customer.features.messages.usage} / {customer.features.messages.included_usage}
* {/if} * ``` */ export function useCustomer() { const autumn = getAutumnContext(); if (!autumn) { throw new Error( "No Autumn client found in context. Did you forget to call setupAutumn()?", ); } return { get customer() { return autumn.customer; }, allowed: autumn.allowed, check: autumn.check, checkout: autumn.checkout, track: autumn.track, attach: autumn.attach, cancel: autumn.cancel, openBillingPortal: autumn.openBillingPortal, createEntity: autumn.createEntity, getEntity: autumn.getEntity, setupPayment: autumn.setupPayment, createReferralCode: autumn.createReferralCode, redeemReferralCode: autumn.redeemReferralCode, listProducts: autumn.listProducts, usage: autumn.usage, query: autumn.query, listEvents: autumn.listEvents, aggregateEvents: autumn.aggregateEvents, refetch: autumn.refetch, }; } /** * Check if Autumn has been set up in the current context */ export function isAutumnSetup(): boolean { return hasAutumnContext(); } /** * Helper for managing loading, error, and result state for Autumn operations. * * Reduces boilerplate when calling async billing operations like checkout, track, etc. * Returns reactive state ($state runes) that automatically updates during operation execution. * * @see {@link useAutumnOperation} for detailed documentation and examples */ export { useAutumnOperation } from "./client.svelte.js"; // Re-export types for convenience export type { Customer, Entity, Feature, Product, ProductItem, CheckParams, CheckResult, CheckoutParams, CheckoutResult, TrackParams, TrackResult, AttachParams, AttachResult, AttachFeatureOptions, CancelParams, BillingPortalParams, BillingPortalResult, CreateEntityParams, GetEntityParams, SetupPaymentParams, SetupPaymentResult, CreateReferralCodeParams, CreateReferralCodeResult, RedeemReferralCodeParams, RedeemReferralCodeResult, SetUsageParams, SetUsageResult, QueryParams, QueryResult, EventRecord, EventListParams, EventListResult, EventAggregateParams, LocalCheckResult, RefetchOptions, AutumnConvexApi, } from "../svelte/types.js"; export type { AutumnServerState, InvalidateFunction } from "./client.svelte.js";