In Nuxt 3, imports can reference the project root using either ~
or @
, for example:
import SubHeader from "@/components/SubHeader.vue"
vs
import SubHeader from "~/components/SubHeader.vue"
Is there a functional difference between these? Is one preferred over the other?
Both @
and ~
are valid in Nuxt, you can choose what you prefer.
It is worth mentioning that the core members of Nuxt prefer ~
because it is much safer in edge cases where @
has special meaning in toolings. You can see now that the official docs only use ~
in the examples.
Ref: https://github.com/nuxt/nuxt/pull/24574#issuecomment-1841628599