Utilities

Auto-imported helper functions for common tasks across DocLayer

Internally we've built a set of utility helpers to streamline common tasks across the codebase. These utilities are designed to be small, focused functions that can be reused in various contexts, such as components, composables, macros, and server/runtime code.

Global Context

All of these utilities are auto-imported, globally accessible and can be used with application-based context without needing to import them. Additionally, some of them are also exported from the @vuehouse/dl/exports package for broader use. This allows you to leverage these functions even in environments where the global context is not available (such as server code, runtime code, other utilities, etc.). We will indicate which utilities were exported in their respective sections.

Bellow you'll find a comprehensive list of these utilities with a brief descriptions of their functionality. Where applicable, with examples that illustrate on how to use each effectively.


utilAsyncMap

Asynchronously maps over an array of values.

Example:

const values = [1, 2, 3, 4, 5];const mappedValues = await utilAsyncMap(values, async (value) => {  return value * 2;});// results in: [2, 4, 6, 8, 10]
declare function utilAsyncMap<T, Result = void>(  array: T[],  callback: (item: T, index: number) => Result | Promise<Result>,): Promise<Awaited<Result>[]>;

Utility is especially useful when you need to map over an array of values asynchronously, or perform multiple operations concurrently. It leverages the Promise.all method to wait for all promises to resolve before continuing.

This utility is exported from the module package.

import { utilAsyncMap } from '@vuehouse/dl/exports';

You can use it this way when the global context is not available and utility can't be loaded automatically by Nuxt.


utilBooleanString

Converts a string with boolean-like value to the real Boolean.

Example:

const convertedBoolean = utilBooleanString('true');// results in: true
import type { Nullable } from '@vuehouse/dl/types';declare function utilBooleanString(value: Nullable<string | boolean>): Nullable<boolean>;

Utility can be helpful when converting boolean values defined in Markdown - which are represented as strings - before passing them to a component; either defined as value="true" or value=true.

This utility is exported from the module package.

import { utilBooleanString } from '@vuehouse/dl/exports';

You can use it this way when the global context is not available and utility can't be loaded automatically by Nuxt.


utilCastItem

Converts a given value to a specified type using TypeScript assertions.

Example:

type User = { id: string; name: string };const user = utilCastItem<User>({ id: '1', name: 'Jane' });
declare function utilCastItem<T>(item: any): T;

Utility might be very useful when you want to narrow down types, especially when dealing with dynamic data sources or complex structures.

This utility is exported from the module package.

import { utilCastItem } from '@vuehouse/dl/exports';

You can use it this way when the global context is not available and utility can't be loaded automatically by Nuxt.


utilCollectionCheck

Validates whether a given collection exists in the list of allowed collections.

Example:

// Check "blog" collection, update validator refconst isBlog = utilCollectionCheck('blog');// or with custom reactive validator (side effect)const isCollectionExists = ref(true);const isDocs = utilCollectionCheck('docs', undefined, isCollectionExists);
import type { Nullable, CollectionName } from '@vuehouse/dl/types';import type { Ref } from 'vue';declare function utilCollectionCheck(  collection: Nullable<CollectionName>,  validator: Ref<boolean | undefined> = ref(false),): Nullable<boolean>;

Utility can be very useful to check if a given collection exists when working with Nuxt Content collections. The optional validator is updated as a "side effect".


utilCollectionName

Reads the collection name from the current route.

Example:

const route = useRoute();const collectionName = await utilCollectionName(route);// results in: 'docs', 'blog', etc.
import type { PageCollections } from '@nuxt/content';import type { RouteLocationNormalizedLoaded } from 'vue-router';import type { Ref } from 'vue';declare function utilCollectionName<Collection extends keyof PageCollections>(  route: RouteLocationNormalizedLoaded,  routesWildcard?: RouteLocationNormalizedLoaded['name'][],): Promise<Ref<Collection>>;

Utility is useful when you need to determine which content collection the current page belongs to. It extracts the collection name from route parameters, path segments, or query parameters. Useful for building dynamic navigation or content filtering.


utilContentBody

Extracts the body object from a page collection data, retrieved from the queryCollection method.

Example:

const body = utilContentBody(pageData);
import type { PageCollectionItemBase } from '@nuxt/content';import type { Nullable } from '@vuehouse/dl/types';import type { Ref } from 'vue';declare function utilContentBody(  collectionData: Nullable<PageCollectionItemBase | Ref<PageCollectionItemBase>>,): Nullable<PageCollectionItemBase['body'] | ReturnType<typeof toValue<PageCollectionItemBase>>['body']>;

Utility unwraps possible Ref values further using the utilObjectParser to normalize the output.


utilContentSeo

Normalizes custom SEO (_seo) and Schema.org (_schemaOrg) metadata into a plain object(s), retrieved from the queryCollection method.

Example:

const [seo, schemaOrg] = utilContentSeo(pageData);// or without schema.orgconst [seo] = utilContentSeo(pageData, false);
import type { Nullable, PrimitiveRecordNested } from '@vuehouse/dl/types';type MetaKeys = 'description' | 'keywords' | 'robots' | 'author' | 'locale';declare function utilContentSeo<ExtendedKeys extends string = MetaKeys>(  pageData: Nullable<Collections[CollectionName] | Ref<Collections[CollectionName]>>,  schemaOrg: boolean = true,): [seo: PrimitiveRecordNested<any, ExtendedKeys>, schemaOrg: PrimitiveRecordNested<any, ExtendedKeys>] | [];

Utility can be helpful with differently defined _seo data formats - object vs. array, set within the content page Frontmatter section. If you don't need Schema.org metadata, you can pass false as the second argument to skip the normalization.

More about defining custom SEO metadata you can read here.


utilDataBody

Extracts the meta.body from a data-type collection, retrieved from the queryCollection method.

Example:

const dataBody = utilDataBody(item);
import type { CollectionItemBase, MarkdownRoot } from '@nuxt/content';import type { Nullable } from '@vuehouse/dl/types';import type { Ref } from 'vue';export type DataCollectionBody<Collection extends CollectionItemBase | Ref<CollectionItemBase> = CollectionItemBase> =  Omit<Collection, 'meta'> & {    meta: { body: MarkdownRoot };  };declare function utilDataBody<Collection extends CollectionItemBase | Ref<CollectionItemBase>>(  collectionData: Nullable<DataCollectionBody<Collection>>,): Nullable<MarkdownRoot>;

Utility unwraps possible Ref values further using the utilObjectParser to normalize the output. Internally it's used to handle sharable Markdown components.


utilEmailParser

Extracts a person's data from an email address by parsing the local part.

Example:

const { first, last, full, email } = utilEmailParser('john.doe@email.com');// results in: John, Doe, John Doe, john.doe@email.com
import type { LooseAutocomplete } from '@vuehouse/dl/types';type UnknownString = 'Unknown';type ParsedNameRecord = {  email: string;  first: LooseAutocomplete<UnknownString>;  last?: LooseAutocomplete<UnknownString>;  full: LooseAutocomplete<UnknownString>;  valid: boolean;};declare function utilEmailParser(email: string, placeholder: UnknownString = 'Unknown'): ParsedNameRecord;

Utility extracts user-friendly name information from an email address. It is used in our Newsletter adapters to generate name data for new mailing list subscribers. The parser skips role-based addresses (like admin, support, hello, contact, etc.) and titles (such as ms, mrs, etc.), returning clean data when possible; if a name cannot be reasonably determined, it will return the string Unknown. You can override the placeholder string with the second argument.

Additionally, the utility returns a boolean value indicating whether the email is valid.

const { valid } = utilEmailParser('john.doe@email.com');// results in: true

This utility is exported from the module package.

import { utilEmailParser } from '@vuehouse/dl/exports';

You can use it this way when the global context is not available and utility can't be loaded automatically by Nuxt.


utilCSSVariable

Builds a CSS variable string from a --var name.

Example:

const color = utilCSSVariable('--css-variable');// results in: var(--css-variable)
type CSSVariableName = `--${string}`;type CSSVariable = `var(${CSSVariableName})`;declare function utilCSSVariable(variantName: CSSVariableName): CSSVariable;

Utility can be helpful while defining dynamic variables or multiple variable definitions within the component's script or template sections.


utilLogMessage

Formats a log message with application tag and source.

Example:

console.warn(utilLogMessage([`Something failed: ${error}`, 'utilLogMessage']));// results in: [app-tag: utilSomething] Something failed
type ResolvedMessage = `[${string}: ${string}] ${string}` | `[${string}${string}] ${string}`;declare function utilLogMessage([message, source, tag]: [string, string?, string?]): ResolvedMessage;

Utility is used throughout the application to format log messages in a consistent and informative way. It helps ensure a unified logging style. By default, the tag is taken from dl.meta.tag, but in some internal utilities, the doclayer tag is hardcoded to clearly indicate the source of internals.

This utility is exported from the module package.

import { utilLogMessage } from '@vuehouse/dl/exports';

You can use it this way when the global context is not available and utility can't be loaded automatically by Nuxt.


utilMDtoHAST

Converts Markdown input into a normalized HAST / Minimark tree.

Example:

const hast = await utilMDtoHAST('**Hello** from Markdown');// or return Minimark-compatible ASTconst minimark = await utilMDtoHAST('**Hello** from Markdown', { toMinimark: true });// or converted to Comark-compatible ASTconst comark = await utilMDtoHAST('**Hello** from Markdown', {  withComponents: true,  // (optional) combined will return Minimark-like object with rendered components  toMinimark: true,});
type HastNodes = ReturnType<typeof import('mdast-util-to-hast').toHast> & { children: any };type MinimarkNodes = ReturnType<typeof import('minimark/hast').fromHast>;type ComarkTree = Awaited<ReturnType<typeof import('comark').parse>>;type ComarkNodes = ComarkTree['nodes'];declare function utilMDtoHAST(  markdown: string,  options?: { toMinimark?: boolean; withComponents?: boolean },): Promise<HastNodes | MinimarkNodes | ComarkNodes>;

Use this utility whenever you need to convert Markdown into an Abstract Syntax Tree (AST) for further processing - such as rendering content or making transformations.

  • By default, the function returns a normalized HAST tree, which is a standard structure for representing HTML.
  • If you pass { toMinimark: true }, the output will be formatted as a Minimark AST, compatible with the Nuxt Content renderer and the DlRenderer component.
  • If you pass { withComponents: true }, the output includes a tree where both custom content and native components are represented, using the Comark library to shape the AST.
  • If you use both { withComponents: true, toMinimark: true } together, you'll get a Minimark-like AST that includes rendered components.

This flexibility allows you to choose exactly the format you need, depending on where and how the parsed Markdown will be used.


utilMDtoHTML

Converts Markdown "tags" into HTML.

Example:

utilMDtoHTML('Use `code` and **bold** _text_');// results in: 'Use <code>code</code> and <strong>bold</strong> <i>text</i>'
declare function utilMDtoHTML(markdown: string): string;

Utility is especially useful when rendering Markdown within inline HTML, most often by using the v-html directive. It handles: backtick code, bold, and italic.

This utility is exported from the module package.

import { utilMDtoHTML } from '@vuehouse/dl/exports';

You can use it this way when the global context is not available and utility can't be loaded automatically by Nuxt.


utilObjectParser

Converts complex object structures into plain ones.

Example:

const plain = utilObjectParser(anyObject);
declare function utilObjectParser<T = unknown, Return = unknown>(  input: T,  bucket: WeakMap<WeakKey, unknown> = new WeakMap(),): Return;

Utility widely used across the codebase to ensure consistent and safe object handling. It can convert proxies and complex data structures (Arrays, Maps, Sets) into plain objects, handle stringified JSON(s), finally guard circular referencing. Use it when you need to safely convert various data types into plain objects.

This utility is exported from the module package.

import { utilObjectParser } from '@vuehouse/dl/exports';

You can use it this way when the global context is not available and utility can't be loaded automatically by Nuxt.


utilPrimitiveWatch

Creates a lightweight watcher for a primitive value(s).

Example:

// Initialize the watcher with a valueconst status = utilPrimitiveWatch(false);// Get the current valuestatus.get(); // false// Watch for changesconst stop = status.watch((resolved, wasResolved) => {  if (resolved) console.log(`Changed from ${wasResolved} to ${resolved}`);});// Set wherever you want to update the value, being notified when it changes.status.set(true); // logs: "Changed from false to true"// Remove listenerstop();
import type { Primitive } from '@vuehouse/dl/types';type WatchCallback = (newValue: Primitive, oldValue: Primitive) => void;declare function utilPrimitiveWatch<Value extends Primitive>(  value: Value,): {  get(): Value;  set(newValue: Value): void;  watch(callback: WatchCallback): () => void;  unwatch(callback: WatchCallback): ReturnType<typeof utilPrimitiveWatch<Value>>;};

Utility provides a simple pub/sub wrapper around a single primitive. It works outside Vue component context - useful in module setup, server/runtime code, or anywhere Vue composables are not available.

Listeners are called synchronously when set() runs. If you register twice the same callback, it will run twice.

Not Vue reactivity

Unlike Vue ref or watch, this utility does not integrate with the component lifecycle. Call the function returned from watch() to unsubscribe when cleanup is needed. Always call methods on the returned object (watcher.watch(...)) - destructuring watch can break unsubscribe.

This utility is exported from the module package.

import { utilPrimitiveWatch } from '@vuehouse/dl/exports';

You can use it this way when the global context is not available and utility can't be loaded automatically by Nuxt.


utilSafeImport

Safely imports a module with timeout.

Example:

const module = await utilSafeImport('some-module' /* { ...config } */);if (module) {  // use the imported module}
import type { JitiOptions } from 'jiti';type SafeImportConfig = Partial<{  /** Suppress warning logs when the import fails or time's out. */  silent: boolean;  /** Timeout in milliseconds. Defaults to `100` (native) or `2000` (with `ts`) when `ts` is set. */  timeout: number;  /** Tag for warning output (e.g. module name that calling this utility). */  source: string;  /** Evaluate TypeScript via jiti (same approach as Nuxt). */  ts: boolean | JitiOptions;}>;declare function utilSafeImport<Import = unknown | null>(specifier: string, config?: SafeImportConfig): Promise<Import>;

Use this utility when attempting to dynamically import a module. If the import fails, or takes longer than the configured timeout, it returns null instead of throwing or hanging. Especially useful for dynamic, user-initiated, or optional imports, where reliability and responsiveness are critical. Below you can see the configuration options that are available:

OptionDefaultDescription
silentfalse

Skips warning logs on failure.

timeout

- 100
- 2000 for ts mode

Max wait before the import is treated as failed. Time in milliseconds.

sourceundefined

Tag for warning output (e.g. module name that calling this utility).

tsfalse

Resolves TypeScript files with Jiti.

When to enable ts option

Because native import() cannot evaluate TypeScript files (Node does not understands that) set ts option to true when loading any TypeScript files, local .ts modules, or any specifier that depends on package export conditions. Pass JitiOptions instead of true to customize aliases or other Jiti settings for a one-off import.

Simple example would be with loading app.config.ts file:

const { default: appConfig } = await utilSafeImport('app.config.ts', {  ts: true,});

This utility is exported from the module package.

import { utilSafeImport } from '@vuehouse/dl/exports';

You can use it this way when the global context is not available and utility can't be loaded automatically by Nuxt.


utilShikiHighlighter

Returns the globally initialized Shiki highlighter instance.

Example:

<script setup lang="ts">// Call existing highlighter instanceconst highlighter = await utilShikiHighlighter();// Call new highlighter instance with custom configconst highlighter = await utilShikiHighlighter({  themes: { dark: 'nord', light: 'nord-light' },  langs: ['typescript', 'javascript', 'json'],});// Highlight codeconst highlightedCode = highlighter.codeToHtml(code, {  lang: 'typescript',  theme: 'github-dark-default',});</script>
import type { Highlighter } from '@vuehouse/dl/types';declare async function utilShikiHighlighter(customConfig?: Highlighter): Promise<ReturnType<typeof import('shiki/bundle/web').createHighlighter>>;

Utility provides access to the Shiki syntax highlighter instance, which is initialized once and globally, based on the dl.components.DlCode component configuration. Use it to generate highlighted code blocks with support for multiple languages and themes.

New instance of the Shiki highlighter

If you provide a customConfig object, a new instance of the Shiki highlighter will be created with the specified configuration instead of returning the global one. This is useful when you need different highlighting settings for specific use cases and/or single components.


utilSafeHTML

Sanitizes HTML client-side.

This utility is intended to work with the Vue component's template structure only. It contains the Nuxt runtime internals and should not be used outside of the component context.

Example:

<template>  <div v-html="utilSafeHTML('unsafeHTML')"></div>  <!-- Disabled locally, per usage -->  <div v-html="utilSafeHTML('unsafeHTML', true)"></div></template>
declare function utilSafeHTML(html: string, localDisable: boolean = false): string;

Enabled by default

By default, HTML that is loaded dynamically is sanitized on the client side. This is primarily relevant for components using the Vue. Global sanitization is controlled by the sanitizeHTML property - set this to false to disable sanitization everywhere. For new components, you can also disable it locally as needed, which might be helpful if you want to override the global setting.

Server-side sanitization is not performed, assuming that server-rendered data is already secure. Sanitization is also disabled for DlCode component code blocks, since the variety of code data can lead to improper escaping.

Utility might be very helpful when rendering dynamic HTML content from potentially untrusted sources - such as user inputs or external APIs - particularly when using inline HTML inserts with the v-html directive in templates.


utilSlugGen

Generates URL-friendly slugs.

Example:

utilSlugGen('Hello World!');// results in: 'hello-world'utilSlugGen('/Docs/01.index.md', 'path');// results in: '/docs'
type SlugType = 'simple' | 'path';declare function utilSlugGen(value: unknown, type?: SlugType): string;

Utility is used to generate slugs from content paths, such as for the dl.pathMap (used by the DlLink component), and other internal modules. It is useful whenever you need to create URL-friendly strings from arbitrary input.

It supports two modes: simple and path. The path mode handles extensions, camel-case, diacritics, numbered segments, double slashes, trailing index, spaces, and casing.

This utility is exported from the module package.

import { utilSlugGen } from '@vuehouse/dl/exports';

You can use it this way when the global context is not available and utility can't be loaded automatically by Nuxt.


utilThrottle

Immediate-leading throttle with per-callback state storing.

Example:

const { callback: onClick, pending } = utilThrottle(() => doSomething(), ref(false), 1000);onClick();
import type { Ref } from 'vue';import type { ThrottleFunction } from '@vuehouse/dl/types';declare function utilThrottle<Callback extends ThrottleFunction>(  callback: Callback,  pending: Ref<boolean> = ref(false),  timeout: number = 1000,): { callback: Callback; pending?: Ref<boolean> };

Utility uses an internal caching mechanism to store state of each callback, ensuring that every throttled function maintains its own timing and execution context, without leaking. You can use it to limit how frequently a function can be called, such as user's interactions with an UI or events. It's used for copy-to-clipboard functionality in the DlCode component.

You can pass your own pending state to have it updated accordingly, or simply use the pre-built one. The initial timeout is set to 1000ms = 1s, but you can customize it as needed.

This utility is exported from the module package.

import { utilThrottle } from '@vuehouse/dl/exports';

You can use it this way when the global context is not available and utility can't be loaded automatically by Nuxt.


utilTWC

Builds Tailwind class(es) string from array or a tuple-builder.

Example:

const classes = utilTWC(['px-4', shouldHighlight && 'bg-yellow-100']);// results in: 'px-4 bg-yellow-100'const classes = utilTWC((resolver) => resolver(['px-4', 'py-2', isActive ? 'text-brand-500' : 'text-neutral-400']));// results in: 'px-4 py-2 text-brand-500'
import type { LooseAutocomplete, ArrayToString } from '@vuehouse/dl/types';type TailwindClass = (typeof import('#build/doclayer/twcl-compressed').default)[number];type TailwindClassUnion = LooseAutocomplete<TailwindClass>[];declare function utilTWC<ClassList extends TailwindClassUnion>(  resolver: (_tuple: typeof buildClassTuple) => ClassList,): ArrayToString<ReturnType<typeof resolver>>;declare function utilTWC<ClassList extends TailwindClassUnion>(resolver: ClassList | TailwindClassUnion): string;declare function utilTWC(resolver: TailwindClassUnion): string;declare function utilTWC(resolver: any): any;

Utility provides a smart way to define Tailwind CSS classes. It accepts an array of class names, with suggestions provided by the TypeScript compiler - all for better DX. The array is resolved into a final string containing the complete CSS class list. It works alongside a special module, which supplies a union type of all valid Tailwind classes available at runtime. This enhances autocomplete and type safety. As a base piece it's integrated into the defineDoclayerComponentUi macro, helping to build component-level UI configurations.

When used with a resolver callback function, it provides type inference for the final classes string directly at the definition level.

This utility is exported from the module package.

import { utilTWC } from '@vuehouse/dl/exports';

You can use it this way when the global context is not available and utility can't be loaded automatically by Nuxt.


utilUID

Generates a short, unique & random identifier.

Example:

const id = utilUID();// results in: 'k2q9af'
declare function utilUID(length: number = 6, chars: string): string;

Utility provides fast, dependency-free UID generation. Use it to create unique identifiers like keys, element IDs, or any situation where a distinct value is needed. You can specify both the length and the character set for the UUID. It uses a fast randomization algorithm based on the given character set, making it much more "predictable" in the final result.


utilWarnPatternCheck

Tests if a warning/error message matches known patterns that are safe to ignore them.

Example:

// check message against predefined patternsif (utilWarnPatternCheck(msg)) return;// with additional custom regexif (utilWarnPatternCheck(msg, [/customRegex/g])) return;
declare function utilWarnPatternCheck(message: string, patterns?: RegExp[]): boolean;

Utility is useful for adding custom or additional warning filters. However, if you override the default warning handlers provided by DocLayer for Vite or Nitro, some warnings that are normally ignored may get logged unnecessarily. To log every suppressed warning, enable dl.dev.debug mode. Keep in mind that this utility is primarily intended to filter out common warnings that have already been well-tested and addressed during the development.

Below you can see the default set of predefined Regex patterns with explanations that are used in DocLayer error/warning handlers: Vue, Vite & Nitro.

const $patterns = [  // Nuxt logs a warning if a custom Nuxt Content component is not found.  // It is a well-known issue: tba  /Failed to resolve component/,  // Nuxt UI cannot recognize custom-generated slots passed to MDC components, so this warning is disabled.  /Slot "(?:[^"]+|default)" invoked outside of the render function/,  // Nuxt occasionally displays a warning when attempting to access `useAsyncData` before the context is available.  // This sometimes occurs inside macros, not causing any real issues.  // [in progress]  /\[useAsyncData\] Component is already mounted/,  // The Tailwind CSS sourcemap (for Vite) is not available during build, so this warning is ignored.  // It is a well-known issue: https://github.com/tailwindlabs/tailwindcss/discussions/16119  /\[plugin @tailwindcss\/vite:generate:build\]/,  // If sitemaps are disabled, Nitro pointing the lack of sourcemaps for external dependencies.  /Sourcemap is likely to be incorrect/,  // Nuxt logs a warning if Chrome requires a devtools configuration file. Disabled for now.  /\.well-known\/appspecific\/com\.chrome\.devtools\.json/,  // Since section links (ToC) are handled manually, the router reports a manual history update.  /history.state seems to have been manually/,  // Nuxt UI has issues rendering dynamic slots in the `Stepper` component-`expose` is mistakenly called per slot.  // [in progress]  /expose\(\) should be called only once/,  // The `manifest-route-rule` middleware is used natively for route rules, so this warning can be safely ignored.  // It is a well-known issue: https://github.com/nuxt/nuxt/issues/30267  /['"]manifest-route-rule['"] middleware already exists/,  /middleware already exists/,  // The scroll behavior is manipulated manually, which leads to router warnings.  /Could(?: not|n't) find element using selector ["']#top["']/,  // The Terser plugin adds this comment to the build, which is not needed and is correct in production builds.  /NO_SIDE_EFFECT/g,  // The app uses virtual paths replaced by Vite. Unrecognized paths may trigger this warning, which is ignored.  /:dl-virtual:/,  // LightningCSS does not recognize some pseudo-classes; this warning is ignored.  // It is a well-known issue: https://github.com/nuxt/nuxt/issues/31041  /\[lightningcss minify\] ['"]deep['"] is not recognized as a valid pseudo-class/,  // Since Vite recognizes double imports (dynamic/virtual), and it's done on purpose,  // to provide access to the config outside the context, the warning has been disabled.  /app\.config\.ts is dynamically imported/,  // Module-provided pages and layouts are not detected by the app, but exists. (TODO: track the issue)  /Your project has pages/,  /Your project has layouts/,  // Vite makes import mismatch over the same component, but defined with runtime params.  /(?:Wrapper|Hero)\.vue is dynamically imported/,];

This utility is exported from the module package.

import { utilWarnPatternCheck } from '@vuehouse/dl/exports';

You can use it this way when the global context is not available and utility can't be loaded automatically by Nuxt.


utilWindowWidth

Checks if window.innerWidth is at least the given width.

Example:

const isDesktop = utilWindowWidth(1024);
declare function utilWindowWidth(windowWidth: number): boolean | undefined;

This utility is exported from the module package.

import { utilWindowWidth } from '@vuehouse/dl/exports';

You can use it this way when the global context is not available and utility can't be loaded automatically by Nuxt.