Billing.js
  • Introduction
  • Features
  • Getting started
    • Installation
    • Add to your app
      • Wrap your app
      • Setup Pricing page
      • Setup Customer Portal
    • Configure Webhooks and Triggers
      • Subscription webhook
      • Customer Webhook
      • New user trigger
  • Guides
    • Single Sign-On
    • Shared subscriptions
    • Local currency support
    • Automatic Dispute Response
  • Components
    • <BillingProvider />
    • Pricing Page
      • <PaymentField />
      • <PaymentSummary />
      • <PromotionCode />
      • <PaymentModal />
    • Customer Portal
      • <CustomerProfile />
      • <Subcriptions />
      • <ManageSharedSubscriptionModal />
      • <PaymentMethods />
      • <Invoices />
  • Hooks
    • useAuth
    • useProducts
  • Methods
    • Product
      • getProducts
    • Customer
      • getCustomerSubscriptions
      • getCustomerPaymentMethods
      • getCustomerInvoices
    • Subscription
      • addSubscription
      • cancelSubscription
      • updateSubscription
    • Payment Method
      • attachPaymentMethodToCustomer
      • detachPaymentMethodFromCustomer
      • setPaymentMethodAsDefault
    • Shared Subscription
      • getSharedSubscription
      • getSharedSubscriptionUsers
      • updateSharedSubscriptionUsers
Powered by GitBook
On this page

Was this helpful?

  1. Hooks

useAuth

useAuth

A custom React hook that manages user authentication and authorization.

Usage



function MyComponent(props) {
  const { signIn, signOut, loading, user } = useAuth()

  // use the signIn, signOut, loading, and user values to render the component
}

Arguments

This hook takes no arguments.

Returns

  • user (User | null): An object representing the authenticated user, or null if no user is authenticated.

  • loading (boolean): A boolean indicating whether the hook is currently in the process of fetching data.

  • signIn (({ hmac, email }: { hmac: any; email: any }) => Promise<void>): A function that accepts an object with two properties, hmac and email, and returns a promise that resolves when the user is signed in.

  • signOut (() => Promise<void>): A function that returns a promise that resolves when the user is signed out.

Previous<Invoices />NextuseProducts

Last updated 2 years ago

Was this helpful?