composables/useBaseUrl

Composable that returns the application's public API base URL from the Nuxt runtime configuration.

Returns

  • API base URL: string — The value of runtimeConfig.public.API_BASE_URL.
composables/useBaseUrl
Returns
string: The public API base URL.

composables/useHistoryState

Composable that provides a reactive reference to the browser's history state.

It initializes with the current history.state and updates automatically whenever the user navigates through the browser history (back/forward navigation).

Event listener is cleaned up automatically when the component is unmounted.

Returns

  • historyState: Ref<object> — A reactive reference containing the current history state.
composables/useHistoryState
Returns
Ref<object>: Reactive history state object.

composables/useObjectTrack

Composable that tracks changes in a reactive object.

It compares the initial state of the object with the latest state
using snapshots from useRefHistory.

If any property differs, isNotEqual becomes true.

Returns

  • isNotEqual: Ref<boolean> — Becomes true if the object has changed.
  • reset: Function — Reset the tracked history to the current state.
  • clear: Function — Clear the entire tracked history.
composables/useObjectTrack
Parameters
object (Ref<object>) A reactive object to track.
Returns
{isNotEqual: Ref<boolean>, reset: Function, clear: Function}:

composables/usePersianTimeAgo

Composable that provides a reactive "time ago" string in Persian (Farsi).

It uses date-fns-jalali to calculate the distance between the given date and the current time, formatted with Persian locale (faIR).

The value updates automatically every 60 seconds.

Returns

  • timeAgo: Ref<string> — A reactive string like "۲ دقیقه پیش".
composables/usePersianTimeAgo
Parameters
date (Date) The date to compare against the current time.
Returns
Ref<string>: A reactive string containing the relative Persian time.

composables/useTimer

Composable that provides a countdown timer with start and reset functionality.

The timer counts down from the given duration (in milliseconds) and optionally calls a callback function when finished.

Returns

  • isPending: Ref<boolean>true if the timer is currently running.
  • timer: Ref<number> — The remaining time in seconds.
  • reset: Function — Resets the timer to the initial duration and stops it.
  • start: Function — Starts the countdown timer.
composables/useTimer
Parameters
props (Props) Timer configuration.
Name Description
props.duration number Duration of the timer in milliseconds.
props.callback Function? Optional callback to run when the timer finishes.
Returns
{isPending: Ref<boolean>, timer: Ref<number>, reset: Function, start: Function}: Timer state and controls.

plugins/bus

Nuxt plugin that provides a lightweight event bus using mitt.

The event bus allows different parts of the application to communicate through events without requiring direct references.

It exposes three main methods:

  • on → Listen for an event
  • off → Stop listening for an event
  • emit → Trigger an event
plugins/bus
Example
// Injected as `bus` in your app
const { $bus } = useNuxtApp();

// Listen for an event
$bus.on("my-event", (payload) => {
  console.log("Received:", payload);
});

// Emit an event
$bus.emit("my-event", { foo: "bar" });

// Stop listening
$bus.off("my-event", handler);

plugins/gsap

Nuxt plugin that integrates GSAP (GreenSock Animation Platform) and registers common GSAP plugins for use in the application.

Registered plugins:

  • ScrollTrigger → Enables scroll-based animations.
  • ScrollToPlugin → Allows smooth scrolling to elements or positions.
  • TextPlugin → Animates text content changes.

Provides global access to:

  • gsap → Core GSAP animation library.
  • ScrollTrigger → ScrollTrigger plugin instance.
plugins/gsap

utils/byteFormatter

Converts a number of bytes into a human-readable string with appropriate units.

Examples:

  • 1024 → "1 Kb"
  • 1048576 → "1 Mb"

Parameters

  • bytes: number — The number of bytes to format.
  • decimals: number — Optional number of decimal places (default: 2).

Returns

  • string — Formatted string with the size and unit (e.g., "1.23 Mb").
utils/byteFormatter
Parameters
bytes (number) The number of bytes to format.
decimals (number = 2) Number of decimal places.
Returns
string: Human-readable byte size.

utils/ensureFileExists

Ensures that a file exists at the given path.

If the file does not exist, it creates the necessary directories and writes the file with the specified initial content.

Parameters

  • filePath: string — The path of the file to ensure.
  • initialContent: string — Optional initial content to write if the file does not exist (default: "").

Returns

  • Promise<void> — Resolves when the file exists or has been created.
utils/ensureFileExists
Parameters
filePath (string) Path to the file to ensure.
initialContent (string = "") Content to write if the file does not exist.
Returns
Promise<void>: Resolves when the file exists or is created.

utils/formatAgent

Parses a user agent string and returns an object describing the operating system, browser, browser version, and device type.

Parameters

  • userAgent: any — The user agent string to parse.

Returns

  • { os: string, browser: string, browserVersion: string, deviceType: string } | undefined — An object containing the detected OS, browser, browser version, and device type, or undefined if no user agent is provided.
utils/formatAgent
Parameters
userAgent (any) The user agent string to analyze.
Returns
{os: string, browser: string, browserVersion: string, deviceType: string}: Object with OS, browser, browser version, and device type, or undefined.

utils/formatPrice

Formats a number as a Persian currency string.

Uses Intl.NumberFormat with the "fa-IR" locale and IRR currency. Replaces the default "ریال" text with a custom currency symbol.

Parameters

  • price: number — The numeric value to format.
  • symbol: string — Optional currency symbol to replace "ریال" (default: "تومان").

Returns

  • string — Formatted price string, e.g., "۱,۰۰۰ تومان".
utils/formatPrice
Parameters
price (number) The number to format.
symbol (string = "تومان") Currency symbol to display.
Returns
string: Formatted Persian currency string.

utils/isImage

Checks if a file name has an image extension.

Supported image types: .jpg, .jpeg, .png, .svg, .webp.

Parameters

  • name: string | undefined — The file name to check.

Returns

  • booleantrue if the file name ends with a supported image extension, otherwise false.
utils/isImage
Parameters
name (string) File name to check (optional).
Returns
boolean: Whether the file is an image.

utils/toEnglishNumber

Converts Persian (Farsi) digits in a string to English digits.

For example, "۱۲۳۴" becomes "1234".

Parameters

  • persianNumberString: string — The string containing Persian digits to convert.

Returns

  • string — A new string with all Persian digits replaced by English digits.
utils/toEnglishNumber
Parameters
persianNumberString (string) String containing Persian digits.
Returns
string: Converted string with English digits.

utils/toReadableDateString

Converts a JavaScript Date object into a readable Persian calendar date string.

The function uses @internationalized/date to convert the Gregorian date to the Persian calendar and formats it as YYYY-MM-DD - HH:MM:SS by default.

You can optionally hide the date or time by providing the format object.

Parameters

  • date: Date — The JavaScript Date object to convert.
  • format: object — Optional formatting options:
    • date: "full" or "none" — Whether to include the date (default "full").
    • time: "full" or "none" — Whether to include the time (default "full").

Returns

  • string — Formatted Persian calendar date string.
utils/toReadableDateString
Parameters
date (Date) The Date object to convert.
format (object?) Optional formatting options (see above).
Returns
string: Persian calendar date and time string.