@nuxt/docs-nightly 5.0.0-29753131.8b68f17a → 5.0.0-29753152.48886c58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -47,3 +47,7 @@ The way `app/utils/` auto-imports work and are scanned is identical to the [`app
47
47
  These utils are only available within the Vue part of your app. :br
48
48
  Only `server/utils` are auto-imported in the [`server/`](/docs/4.x/directory-structure/server#server-utilities) directory.
49
49
  ::
50
+
51
+ ::tip
52
+ Types can be auto-imported the same way. Put app-only types in `app/types/`, server-only types in [`server/types/`](/docs/4.x/directory-structure/server#server-types), and types shared between both in [`shared/types/`](/docs/4.x/directory-structure/shared).
53
+ ::
@@ -166,6 +166,26 @@ Auto-imports and other types are different for the `server/` directory, as it is
166
166
 
167
167
  By default, Nuxt 4 generates a [`tsconfig.json`](/docs/4.x/directory-structure/tsconfig) which includes a project reference covering the `server/` folder which ensures accurate typings.
168
168
 
169
+ Types placed in `~~/server/types/` are auto-imported in the server context only, so you can reference them in server routes, middleware, plugins, and utilities without importing them. Types that are also needed in the Vue app belong in [`shared/types/`](/docs/4.x/directory-structure/shared) instead.
170
+
171
+ ```ts twoslash [server/types/todo.ts]
172
+ export interface Todo {
173
+ id: string
174
+ title: string
175
+ completed: boolean
176
+ }
177
+ ```
178
+
179
+ ```ts [server/api/todos.get.ts]
180
+ import { defineEventHandler } from 'nitro/h3'
181
+
182
+ export default defineEventHandler((): Todo[] => {
183
+ return []
184
+ })
185
+ ```
186
+
187
+ Only files directly in `server/types/` are scanned; files in nested subdirectories are not auto-imported, matching how [`shared/types/`](/docs/4.x/directory-structure/shared#how-files-are-scanned) works.
188
+
169
189
  ## Recipes
170
190
 
171
191
  ### Route Parameters
@@ -31,6 +31,8 @@ Server-only code (such as Node APIs, Nitro utilities, or server route handlers)
31
31
 
32
32
  `import type` is erased at compile time and does not pull runtime code into the other bundle, so importing only types across the boundary may appear to work. Even so, keep shared types (such as API response types) in `shared/types/`, where they are auto-imported in both contexts. This keeps the boundary clear, avoids accidentally turning a type import into a value import later, and matches Nuxt's separate [type contexts](/docs/4.x/guide/concepts/typescript#project-references) for app, server, and shared code.
33
33
 
34
+ Types that are only used in one context can live next to that context instead: `app/types/` is auto-imported in the Vue app only, and [`server/types/`](/docs/4.x/directory-structure/server#server-types) is auto-imported in the Nitro server only. Use `shared/types/` when a type is needed in both.
35
+
34
36
  :video-accordion{title="Watch a video from Vue School on sharing utils and types between app and server" videoId="nnAR-MO3q5M"}
35
37
 
36
38
  ## Usage
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/docs-nightly",
3
- "version": "5.0.0-29753131.8b68f17a",
3
+ "version": "5.0.0-29753152.48886c58",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",