mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-19 16:01:24 +00:00
docs: add mention of addServerTemplate
to modules guide (#31369)
This commit is contained in:
parent
d7ee76bbb8
commit
cc5be870d7
@ -579,6 +579,22 @@ export default defineNuxtModule({
|
||||
})
|
||||
```
|
||||
|
||||
For the server, you should use the `addServerTemplate` utility instead.
|
||||
|
||||
```ts
|
||||
import { defineNuxtModule, addServerTemplate } from '@nuxt/kit'
|
||||
|
||||
export default defineNuxtModule({
|
||||
setup (options, nuxt) {
|
||||
// The file is added to Nitro's virtual file system and can be imported in the server code from 'my-server-module.mjs'
|
||||
addServerTemplate({
|
||||
filename: 'my-server-module.mjs',
|
||||
getContents: () => 'export const myServerModule = () => "hello world !"'
|
||||
})
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
#### Adding Type Declarations
|
||||
|
||||
You might also want to add a type declaration to the user's project (for example, to augment a Nuxt interface
|
||||
|
Loading…
Reference in New Issue
Block a user