API reference

Business modules

Data and actions of orders, products, customers, invoices, learning, account and help center.

Orders, products, customers, invoices and learning load their data through a provider (options.provider, a mock by default) and return ready, a promise to await before reading a record at setup (if (!loaded.value) await ready; create every useId() above that line, because on the server the ids made after an await differ from the browser's). The account and the help center read their mocks directly. See Connect your API.

useProviderState()

Shared state loaded once per visit from a provider; the server waits for it before rendering. It also returns error (the message of a failed load), refresh() (loads the provider again) and sync, which runs a provider call in the background and, when it fails, shows a toast and reloads the data so the screen never keeps a change the backend rejected.

composables/useProviderState.ts
useProviderState(key: string, load: () => Promise<T>, empty: () => T): { state: any; ready: any; loaded: any; error: any; refresh: () => Promise<void | undefined>; sync: (task: Promise<unknown>) => void; }
Returnsstatereadyloadederrorrefreshsync

useProviderSync()

Runs a provider call in the background and shows a toast if it fails; pass a function (such as refresh) to run after the failure. Module composables use the sync that useProviderState() returns, already wired to refresh.

composables/useProviderState.ts
useProviderSync(onFailure?: () => Promise<unknown>): (task: Promise<unknown>) => void

useOrders()

Orders with lookups and status actions: advance, cancel and refund.

composables/useOrders.ts
useOrders(options: UseOrdersOptions = {}): { orders: any; ready: any; loaded: any; error: any; refresh: any; findOrder: (id: string) => any; findProduct: (code: string) => Product | undefined; ordersOf: (customerId: string…
ReturnsordersreadyloadederrorrefreshfindOrderfindProductordersOfadvancecancelrefundmarkPaidaddComment

orderTotals()

Subtotal, discount, shipping, tax and total of an order.

composables/useOrders.ts
orderTotals(order: Order): OrderTotals
Returnssubtotaltaxshippingdiscounttotalunits

orderLines()

The lines of an order with their products and category icons.

composables/useOrders.ts
orderLines(order: Order): OrderLine[]

nextOrderStatus()

The status that follows the current one.

composables/useOrders.ts
nextOrderStatus(status: OrderStatus): "processing" | "shipped" | "delivered" | "cancelled" | "refunded" | undefined

useProducts()

Products: save, duplicate, restock, change status and remove.

composables/useProducts.ts
useProducts(options: UseProductsOptions = {}): { products: any; ready: any; loaded: any; error: any; refresh: any; findProduct: (code: string) => any; nextCode: () => string; save: (product: Product) => void; setStatus: (codes…
ReturnsproductsreadyloadederrorrefreshfindProductnextCodesavesetStatusremoveduplicaterestock

useProductForm()

The create/edit form of a product with its sections and code generation.

composables/useProductForm.ts
useProductForm(items: MaybeRefOrGetter<Product[]>): { isOpen: any; isSaving: any; editing: any; values: any; sections: any; title: any; create: () => void; edit: (product: Product) => void; nextCode: () => string; toProduct: (submi…
ReturnsisOpenisSavingeditingvaluessectionstitlecreateeditnextCodetoProduct

useCustomers()

Customers: save, remove and manage notes.

composables/useCustomers.ts
useCustomers(options: UseCustomersOptions = {}): { customers: any; ready: any; loaded: any; error: any; refresh: any; findCustomer: (id: string) => any; save: (customer: Customer) => void; remove: (ids: string[]) => void; addNot…
ReturnscustomersreadyloadederrorrefreshfindCustomersaveremoveaddNoteremoveNotenextId

useInvoices()

Invoices and clients: save, send, remind, record payments, mark paid, duplicate and remove.

composables/useInvoices.ts
useInvoices(options: UseInvoicesOptions = {}): { invoices: any; ready: any; loaded: any; error: any; refresh: any; clients: any; find: (id: string) => any; nextId: (issued?: string) => string; save: (invoice: Invoice) => void;…
ReturnsinvoicesreadyloadederrorrefreshclientsfindnextIdsavesetStateremindrecordPaymentmarkPaidduplicateremove

useLearning()

Courses, students and instructors with every lookup and action of the learning module.

composables/useLearning.ts
useLearning(options: UseLearningOptions = {}): { state: any; ready: any; loaded: any; error: any; refresh: any; coursesById: any; findCourse: (id: string) => any; studentsOf: (courseId: string) => any; setCourseStatus: (id: st…
ReturnsstatereadyloadederrorrefreshcoursesByIdfindCoursestudentsOfsetCourseStatusinstructorOfstatsOffindInstructorcoursesOfsaveInstructorremoveInstructorstudentSummaryenrollmentOffindStudentlessonOfenrollsaveCourseduplicateCourseremoveCoursesaveStudentremoveStudents

useCourseDuration()

Formats course minutes as hours and minutes.

composables/useLearning.ts
useCourseDuration(): { duration: (minutes: number) => any; }
Returnsduration

useInstructorTiles()

The five stat tiles of an instructor profile.

composables/useLearning.ts
useInstructorTiles(): { tiles: (instructor: Instructor, stats: ReturnType<typeof instructorStats>) => ({ label: any; value: any; hint: any; hintClass: string | undefined; icon?: undefined; iconColor?: …
Returnstiles

useStudentTimeline()

The activity of a student as timeline items.

composables/useLearning.ts
useStudentTimeline(): { timeline: (student: Student, limit?: number) => TimelineItem[]; }
Returnstimeline

useCourseForm()

The create/edit form of a course.

composables/useCourseForm.ts
useCourseForm(): { panel: any; title: any; sections: any; create: () => void; edit: (course: Course) => void; submit: (values: FormValues) => Course; }
Returnspaneltitlesectionscreateeditsubmit

useStudentForm()

The student form and the enrol form.

composables/useStudentForm.ts
useStudentForm(): { panel: any; title: any; fields: any; create: () => void; edit: (student: Student) => void; submit: (values: FormValues) => void; enrollPanel: any; enrollStudent: any; enrollFiel…
ReturnspaneltitlefieldscreateeditsubmitenrollPanelenrollStudentenrollFieldsopenEnrollsubmitEnroll

useInstructorForm()

The invite/edit form of an instructor.

composables/useInstructorForm.ts
useInstructorForm(): { panel: any; isEditing: any; title: any; fields: any; create: () => void; edit: (instructor: Instructor) => void; submit: (values: FormValues) => void; }
ReturnspanelisEditingtitlefieldscreateeditsubmit

useAccount()

Profile, sessions, notifications, security, preferences, billing and subscription of the account area.

composables/useAccount.ts
useAccount(): { profile: any; sessions: any; notifications: any; digest: any; quietHours: any; billingDetails: any; subscription: any; security: any; preferences: any; billingHistory: any; upda…
ReturnsprofilesessionsnotificationsdigestquietHoursbillingDetailssubscriptionsecuritypreferencesbillingHistoryupdateSecurityupdatePreferencesupdateProfileplansplanFeaturesrevokeSessionrevokeOtherSessionssetNotificationplanPrice

useHelpCenter()

Articles, categories, FAQ, search, related articles and suggestions of the help center.

composables/useHelpCenter.ts
useHelpCenter(): { allArticles: any; categories: any; faq: any; popularSearches: any; updates: any; tickets: any; search: (query: string, category?: HelpCategoryId) => any; findArticle: (slug: str…
ReturnsallArticlescategoriesfaqpopularSearchesupdatesticketssearchfindArticlerelatedTosuggest
© 2026 melsami UI.
Developer documentation for melsami UI.