mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-20 08:15:59 +00:00
docs: add mention of addServerTemplate
to modules guide (#31369)
This commit is contained in:
parent
9f427e5f8c
commit
2e2f6475b4
@ -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