Files
gil-wiki/reference/2.directory-structure/1.app/1.utils.md
gil 5f664546cf feat: 위키 저장소 초기 커밋
- CLAUDE.md 운영 규칙
- wiki/ 정리된 지식 페이지 (Nuxt + Claude Code)
- raw/ 원본 자료
- reference/ Nuxt 4.x 공식 문서

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 00:31:51 +09:00

1.5 KiB

title, head.title, description, navigation.icon
title head.title description navigation.icon
utils utils/ Use the utils/ directory to auto-import your utility functions throughout your application. i-vscode-icons-folder-type-tools

The main purpose of the app/utils/ directory is to allow a semantic distinction between your Vue composables and other auto-imported utility functions.

Usage

Method 1: Using named export

export const { format: formatNumber } = Intl.NumberFormat('en-GB', {
  notation: 'compact',
  maximumFractionDigits: 1,
})

Method 2: Using default export

// It will be available as randomEntry() (camelCase of file name without extension)
export default function (arr: Array<any>) {
  return arr[Math.floor(Math.random() * arr.length)]
}

You can now use auto imported utility functions in .js, .ts and .vue files

<template>
  <p>{{ formatNumber(1234) }}</p>
</template>

:read-more{to="/docs/4.x/guide/concepts/auto-imports"}

:link-example{to="/docs/4.x/examples/features/auto-imports"}

::tip The way app/utils/ auto-imports work and are scanned is identical to the app/composables/ directory. ::

::important These utils are only available within the Vue part of your app. :br Only server/utils are auto-imported in the server/ directory. ::