In the rest of the migration documentation, you will notice that key Nuxt and Vue utilities do not have explicit imports. This is not a typo; Nuxt will automatically import them for you, and you should get full type hinting if you have followed the instructions to use Nuxt’s TypeScript support.
How Auto-imports Work
Nuxt 3 will automatically import:- Components from the
components/directory - Composables from the
composables/directory - Vue APIs like
ref,computed,watch, etc. - Nuxt utilities like
navigateTo,useRoute,useRouter, etc.
Migration from @nuxt/components
If you have been using@nuxt/components in Nuxt 2, you can remove components: true in your nuxt.config.
If you had a more complex setup, note that the component options have changed somewhat. See the components documentation for more information.
Benefits of Auto-imports
- Less boilerplate - No need to write import statements for commonly used utilities
- Better developer experience - Focus on your logic, not on managing imports
- Type safety - Full TypeScript support with auto-generated type definitions
- Tree-shaking - Only imported code is included in your bundle
Explicit Imports
If you prefer explicit imports, you can disable auto-imports in yournuxt.config:
#imports:
Custom Auto-imports
You can configure custom auto-imports in yournuxt.config:
Debugging Auto-imports
To see what Nuxt has auto-imported, check these generated files:.nuxt/types/components.d.ts- Auto-imported components.nuxt/types/imports.d.ts- Auto-imported composables and utilities