服务器

了解如何从 Nuxt 2 迁移到 Nuxt 3 服务器。

在构建好的 Nuxt 3 应用中,不存在运行时 Nuxt 依赖。这意味着你的网站将具有极高的性能和极简的体积。但这也意味着你不能再挂载运行时的 Nuxt 服务器钩子。

Read more in Docs > Guide > Concepts > Server Engine.

步骤

  1. 删除 nuxt.config 中的 render 键。
  2. ~/server/api~/server/middleware 中的任何文件都会被自动注册;你可以从 serverMiddleware 数组中移除它们。
  3. serverMiddleware 数组中的其他项目更新为直接指向文件或 npm 包,而不是使用内联函数。
Read more in Docs > Guide > Directory Structure > Server.
Read more in Docs > Guide > Going Further > Hooks#server Hooks Runtime.