N
Nuxt10mo ago
Flo

Can't define server plugin in custom module

I tried following the docs: https://nuxt.com/docs/api/kit/nitro#examples-3 Result: Cannot find name 'defineNitroPlugin'
Nuxt
Nitro · Nuxt Kit
Nuxt Kit provides a set of utilities to help you work with Nitro. These functions allow you to add server handlers, plugins, and prerender routes.
1 Reply
Flo
FloOP10mo ago
import { defineNuxtModule, addServerPlugin, createResolver } from '@nuxt/kit'
import { useLogger } from 'nuxt/kit'

// Module options TypeScript interface definition
export interface ModuleOptions {}

export default defineNuxtModule<ModuleOptions>({
meta: {
name: 'k8s',
configKey: 'k8s'
},
// Default configuration options of the Nuxt module
defaults: {},
setup (options, nuxt) {
const { resolve } = createResolver(import.meta.url)

const logger = useLogger('k8s/module')
logger.info('Module ready for shenanigans!')

addServerPlugin(resolve('runtime/plugin'))
}
})
import { defineNuxtModule, addServerPlugin, createResolver } from '@nuxt/kit'
import { useLogger } from 'nuxt/kit'

// Module options TypeScript interface definition
export interface ModuleOptions {}

export default defineNuxtModule<ModuleOptions>({
meta: {
name: 'k8s',
configKey: 'k8s'
},
// Default configuration options of the Nuxt module
defaults: {},
setup (options, nuxt) {
const { resolve } = createResolver(import.meta.url)

const logger = useLogger('k8s/module')
logger.info('Module ready for shenanigans!')

addServerPlugin(resolve('runtime/plugin'))
}
})
this one seems to have solved itself ¯\_(ツ)_/¯
Want results from more Discord servers?
Add your server