Composables Documentation
useAuth
Handles user authentication with Supabase integration. Provides methods for signing in, signing up, password management, and profile updates.
Key features:
- Email/password authentication
- User registration with email confirmation
- Password reset functionality
- Profile management
- Loading states and error handling
- Automatic toast notifications
Main methods:
signIn(email, password)- Sign in usersignUp(email, password, metadata)- Register new usersignOut()- Sign out current userresetPassword(email)- Send password reset emailupdatePassword(newPassword)- Update user passwordupdateProfile(data)- Update user profile
Reactive state:
isAuthenticated- Boolean indicating if user is logged inuser- Current user objectloading- Loading stateerror- Error messages
useEmail
Provides email sending functionality with different template types. Supports transactional emails, newsletters, success notifications, and custom messages.
Email types:
- Transactional emails (order confirmations, receipts)
- Success emails (welcome messages, achievements)
- Newsletter emails with articles and CTAs
- Custom emails with HTML/text content
Main methods:
sendTransactionalEmail(data)- Send order confirmations and receiptssendSuccessEmail(data)- Send welcome and success messagessendNewsletterEmail(data)- Send newsletter with articlessendCustomEmail(data)- Send custom HTML/text emailssendOrderConfirmation(orderData)- Quick order confirmationsendWelcomeEmail(userData)- Quick welcome email
All methods return promises and handle errors gracefully.
useEmailTemplate
Advanced email template system with multiple pre-built templates and conditional rendering. Supports various email types with dynamic content compilation.
Template types:
- Newsletter templates with article sections
- Welcome emails with onboarding steps
- Purchase confirmations with order details
- Password reset with secure links
- Notifications and alerts
- Subscription management emails
Main methods:
generateNewsletterEmail(data)- Create newsletter HTMLgenerateWelcomeEmail(data)- Create welcome email HTMLgeneratePurchaseEmail(data)- Create purchase confirmation HTMLgeneratePasswordResetEmail(data)- Create password reset HTMLgenerateNotificationEmail(data)- Create notification HTMLgenerateCustomEmail(data)- Create custom email HTML
Features:
- Conditional content blocks
- Variable substitution
- Fallback templates
- Responsive design
- Brand customization
useModal
Modal dialog management system with different modal types and promise-based interactions. Handles confirmation dialogs, info modals, and user input prompts.
Modal types:
- Confirmation modals with yes/no actions
- Info modals for notifications
- Error modals for error messages
- Success modals for confirmations
- Prompt modals for user input
Main methods:
showConfirmModal(title, message, options)- Returns promise with booleanshowInfoModal(title, message, options)- Show informationshowErrorModal(title, message, options)- Show error messageshowSuccessModal(title, message, options)- Show success messageshowPromptModal(title, inputConfig, options)- Returns promise with input value
Features:
- Promise-based API for easy async handling
- Customizable buttons and styling
- Click outside to close
- Keyboard navigation support
useOAuthHistory
Tracks and manages OAuth provider usage history for improved user experience. Remembers which providers users have used recently.
Key features:
- Tracks last used OAuth providers (GitHub, Google, Apple, Twitter)
- Stores usage history in localStorage
- Provides provider styling and icons
- Recent usage detection (within 30 days)
Main methods:
recordOAuthUsage(provider, email)- Record provider usageclearHistory()- Clear all historygetProviderIcon(provider)- Get icon for providergetProviderName(provider)- Get display namegetProviderColors(provider)- Get styling classes
Reactive state:
lastUsedProvider- Most recently used provideroAuthHistory- Array of recent providershasRecentOAuth- Boolean for recent usage
useOTP
One-time password management for email and SMS verification with Supabase. Handles sending, verifying, and resending OTP codes.
Key features:
- Email OTP verification
- SMS OTP verification (if configured)
- Automatic cooldown timer for resends
- Error handling and user feedback
Main methods:
sendEmailOTP(email)- Send OTP to emailsendPhoneOTP(phone)- Send OTP to phoneverifyEmailOTP(email, token)- Verify email OTPverifyPhoneOTP(phone, token)- Verify phone OTPresendOTP(type, contact)- Resend OTP codereset()- Reset all states
Reactive state:
loading- Operation in progressresendCooldown- Seconds until resend allowederrorMessage- Current error messageisVerified- Verification success status
usePlan
Simple composable for plan management (currently minimal implementation).
Planned features:
- Fetch available plans
- Get specific plan details
- Compare plans functionality
useSubscription
Comprehensive subscription management with Stripe integration. Handles subscription lifecycle, billing, and access control.
Key features:
- Subscription status tracking
- Stripe checkout session creation
- Billing portal access
- Subscription cancellation and resumption
- Feature access control
- User profile management
Main methods:
getCurrentSubscription()- Fetch current subscriptioncreateCheckoutSession(priceId)- Create Stripe checkoutcreateBillingPortalSession()- Create billing portalcancelSubscription(subscriptionId)- Cancel subscriptionresumeSubscription(subscriptionId)- Resume subscriptioncheckAccess(feature)- Check feature access
Reactive state:
subscription- Current subscription objecthasActiveSubscription- Boolean for active statusisPastDue- Boolean for overdue paymentsisCanceled- Boolean for canceled statussubscriptionStatusInfo- Status details with colorsdaysUntilNextBilling- Days until next charge
useSupabase
Simple wrapper for Supabase client initialization with runtime configuration.
Usage: Returns configured Supabase client instance using environment variables.
useToast
Toast notification system with multiple variants and automatic dismissal. Provides user feedback for actions and errors.
Toast variants:
- Default - neutral notifications
- Success - positive feedback
- Error - error messages
- Warning - cautionary messages
- Info - informational messages
Main methods:
addToast(options)- Add custom toastremoveToast(id)- Remove specific toastclearAllToasts()- Remove all toasts
Convenience methods:
toast.success(title, description)- Add success toasttoast.error(title, description)- Add error toasttoast.info(title, description)- Add info toasttoast.warning(title, description)- Add warning toast
Features:
- Auto-dismiss after configurable duration
- Manual dismissal
- Global state management
- Stacking support
useTwitter
Twitter/X integration for fetching tweet data and handling Twitter URLs. Supports both Twitter and X.com domains.
Key features:
- Extract tweet IDs from URLs
- Fetch tweet data via API
- Fallback to oEmbed API
- Support for both twitter.com and x.com
Main methods:
extractTweetId(url)- Extract tweet ID from URLgetTweetData(url)- Fetch complete tweet data
Data structure: Returns tweet object with text, author info, creation date, and engagement metrics.
useDropDown
Dropdown component logic with click-outside handling and keyboard navigation. Manages dropdown state and user interactions.
Key features:
- Open/close state management
- Click outside to close
- Escape key to close
- Automatic event cleanup
Main methods:
open()- Open dropdownclose()- Close dropdowntoggle()- Toggle dropdown state
Reactive state:
isOpen- Current open/closed statedropdownRef- Template ref for dropdown element
useUsage
Usage tracking composable for resource monitoring (currently minimal implementation).
Planned features:
- Track resource usage
- Get current usage statistics
- Check usage limits