import { defineNuxtModule } from '@nuxt/kit'
export default defineNuxtModule((options, nuxt) => {
// `nuxt` provides build-time context
// console.log(nuxt)
})
const nuxtApp = useNuxtApp()
// `nuxtApp` provides a runtime
// console.log(nuxtApp)
import { defineNuxtModule } from '@nuxt/kit'
export default defineNuxtModule((options, nuxt) => {
// `nuxt` provides build-time context
// console.log(nuxt)
})
const nuxtApp = useNuxtApp()
// `nuxtApp` provides a runtime
// console.log(nuxtApp)
Nuxt Modules | Nuxt Layers | ||||
Brings external libraries in Nuxt (Integrations) | Isolate re-usable parts of Nuxt App | ||||
Low-level construct (extends Nuxt core) | High-level construct (extend user features, i.e. UI) |
It’s a two-step process: create & extend
✅ | Create layers |
✅ | Extend them in the nuxt.config.ts |
// nuxt.config.ts (Nuxt app that consumes layers)
export default defineNuxtConfig({
extends: [
'../base', // Local layer
'@my-themes/awesome', // NPM package
'github:my-themes/awesome#v1' // Git repository
]
})
npx nuxi init --template layer [layer-name]