---
name: nuxt-explicit-imports
description: Migrate a Nuxt 4 app from auto-imports to explicit imports, one category and directory at a time, with self-verification. Use when removing or disabling Nuxt auto-imports, when you see `[nuxt-explicit-imports]` warnings or strict-mode build errors, or when working with `explicitImports` in `nuxt.config`.
title: nuxt-explicit-imports
canonical_url: https://skilld.dev/gh/antfu/nuxt-explicit-imports
last_updated: 2026-11-17T01:45:50.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/manual-fixes.md](https://skilld.dev/api/skills-raw/antfu/nuxt-explicit-imports/nuxt-explicit-imports/references/manual-fixes.md).
>
> If the user asked to install this Skill, run `npx skilld install antfu/nuxt-explicit-imports/nuxt-explicit-imports`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/nuxt-explicit-imports`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/antfu/nuxt-explicit-imports/nuxt-explicit-imports) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/nuxt-explicit-imports`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/nuxt-explicit-imports --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/nuxt-explicit-imports --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Nuxt explicit imports

`nuxt-explicit-imports` moves a Nuxt app off auto-imports without breaking it. Three **categories** migrate independently:

| Category     | Covers                                                                              |
| ------------ | ----------------------------------------------------------------------------------- |
| `imports`    | Vue and Nuxt composables, your `composables/` and `utils/`, `shared/utils`, module imports |
| `components` | Template tags: your `components/`, `Lazy*` variants, `NuxtLink`, module components    |
| `server`     | Everything auto-imported in `server/`: `defineEventHandler`, `h3`, `server/utils`     |

Each category has a **mode**: `off`, `warn` (auto-imports work, every implicit use is reported) or `strict` (auto-imports are disabled, implicit use fails the build).

The work is a **ratchet**: a category moves `warn` → migrated → verified → `strict`, and never back.

## Tools

- `npx nuxt-explicit-imports check [paths...] [--category <list>] [--json]` lists every implicit use and exits `1` while any remain. It also writes `.nuxt/explicit-imports-report.json` (each finding has `file`, `line`, `name`, `suggestion`, `fixable`, `reason`).
- `npx nuxt-explicit-imports migrate [paths...] [--category <list>] [--dry-run]` writes the explicit imports for every `fixable` finding and lists the rest as manual work.
- In `warn` mode, `nuxi dev` and `nuxi build` print one warning line per file and update the same report.

`check` is the source of truth. It scans every file, including the ones dev never visits.

## Steps

### 1. Set up

1. Install the module: `npx nuxi module add nuxt-explicit-imports`.
2. Set warn mode in `nuxt.config`:

   ```ts
   export default defineNuxtConfig({
     modules: ['nuxt-explicit-imports'],
     explicitImports: { mode: 'warn' },
   })
   ```

3. Run `npx nuxt-explicit-imports check` once and tell the user the totals per category.

Done when `check` runs and prints its summary.

### 2. Record the baseline

Find the project's own gates in `package.json` scripts: typecheck (usually `nuxi typecheck`), lint, tests, build. Run each one and write down which pass and which already fail.

Done when you have a pass/fail entry for every gate. Every later step is judged against this baseline, so a gate that was already failing does not block the migration.

### 3. Migrate one category

Work through the categories in this order: `imports`, then `components`, then `server`. Within a category, take one top-level directory at a time (`app/composables`, `app/pages`, `app/components`, `server/api`, ...). This keeps each diff small enough for the user to review.

For each directory:

1. `npx nuxt-explicit-imports migrate --category <category> <dir>`
2. Fix every finding it lists as manual, using [references/manual-fixes.md](https://skilld.dev/api/skills-raw/antfu/nuxt-explicit-imports/nuxt-explicit-imports/references/manual-fixes.md).
3. Run the lint fixer if the project has one (`eslint --fix`), so the new imports follow the house style.
4. Verify: `npx nuxt-explicit-imports check --category <category> <dir>` exits `0`, and typecheck, lint and tests are no worse than the baseline.
5. Tell the user the directory is migrated and verified. Leave committing to them.

Done when `npx nuxt-explicit-imports check --category <category>` exits `0` for the whole project.

### 4. Make the category strict

1. Set that category to `strict` and keep the others as they are:

   ```ts
   export default defineNuxtConfig({
     explicitImports: {
       mode: { imports: 'strict', components: 'warn', server: 'warn' }
     },
   })
   ```

2. Run the build (`nuxi build`) and the typecheck.
3. If the build fails with `Implicit auto-imports are disabled (strict mode)`, the error lists each file, position and import to add. Run `migrate` on that path, or add the import by hand, then rebuild.

Done when the build and typecheck pass with the category strict and the other gates match the baseline. Then go back to step 3 for the next category.

### 5. Finish

When all three categories are strict, set `explicitImports: { mode: 'strict' }` and run every gate one last time. Done when every gate matches or beats the baseline.

## What strict mode changes

- `imports` strict sets `imports.autoImport: false`. The `#imports` virtual module keeps working.
- `server` strict turns off Nitro's auto-imports (`nitro.imports.autoImport: false`). The module keeps this independent of `imports`, although Nuxt normally links the two.
- `components` strict keeps Nuxt's component registry, so `#components` still exports every component, including `.client`/`.server` ones and islands. Implicit use of a component in a template then fails the build.

## Gotchas

- A finding whose suggestion imports from `#imports` comes from a package path that cannot be imported directly. It works, but tell the user so they can pick a public entry point instead.
- Imports are written from the original source (`vue`, `#app`, `~/composables/foo`, `#server/utils/bar`, `#layers/<name>/...`), never as relative paths. Keep that style when you fix findings by hand.
- These files are skipped on purpose: `*.config.*`, tests (`*.test.*`, `*.spec.*`, `test/`, `tests/`), `.d.ts` files and generated output. Add more with `explicitImports.exclude` (globs relative to the root dir).
