Skip to main content
InterviewHubPRO
Section Overview
Q4

Question 4 of 50

Part 1: Nuxt 3 Fundamentals (Junior / Entry-Level)

8%
Nuxt & Universal SSR (50 Qs)•Part 1: Nuxt 3 Fundamentals (Junior / Entry-Level)

What are Auto-Imports in Nuxt 3 and how do they work?

junior LevelCode ExampleVue & Nuxt

In Simple Words: In Nuxt 3, you do not need to manually write import { ref, computed } from 'vue' or import components and custom composables. Nuxt generates TypeScript declarations in .nuxt/imports.d.ts that make them globally accessible while Vite performs tree-shaking so unused helpers do not bloat the final bundle.

What gets auto-imported?

  1. Vue 3 APIs: ref, reactive, computed, watch, onMounted, nextTick.
  2. Nuxt Built-ins: useRoute, useRouter, useFetch, useAsyncData, useState, navigateTo, useHead.
  3. Your Custom Composables: Any export from composables/*.ts.
  4. Your Components: Any component inside components/ (subfolders become prefixed: components/base/Button.vue -> <BaseButton />).
vue
<!-- No imports required! -->
<script setup lang="ts">
const count = ref(0);
const route = useRoute();
const { user } = useAuth(); // from composables/useAuth.ts
</script>

<template>
  <button @click="count++">Clicked {{ count }} times</button>
</template>