Where should the type live?
The important Nuxt 4 detail is context. The app, server, and shared parts of the project have separate TypeScript contexts.
- app: If the type is only for Vue components, composables, pages, and other app code, put it under
app/, for exampleapp/types/component-props.ts. - server: If the type is only for server routes or Nitro code, put it under
server/, for exampleserver/types/api-response.ts. - shared: If the type is used by both app and server code, put it under
shared/, for exampleshared/types/links.ts, or for ambient globals,shared/types/global.d.ts.
A global.d.ts file is ambient in the context where it lives. app/types/global.d.ts is for app code, server/types/global.d.ts is for server code, and shared/types/global.d.ts is for both.