new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

Nuxt · API · all subjects

advanced features & edge cases

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Server-only types pitfall in app context

When using server-only types in route files (such as types declared in tsconfig.server.json via addServerTemplate), the app context type-checking will not recognize them and will report errors. To resolve this, declare server-only types in both the server context and the app context.

Server routes type-checked in app context

Server routes are type-checked using tsconfig.app.json in addition to tsconfig.server.json because Nuxt infers the return types of server endpoints to provide response types in $fetch and useFetch.

Exclude .output folder from git

Add the '.output' folder to .gitignore when using Nitro, as this is where the built Nitro output is stored and should not be committed to version control.

Remove @nuxt/nitro module when using Bridge

When using Nuxt Bridge, remove the @nuxt/nitro module from package.json because Bridge injects the same functionality automatically.

Never mix Vue and Nitro code

Do not import Vue app code (components, composables, or other app-only utilities) in server routes or utilities, and do not import server-only code in the app. This is fundamental to maintaining proper separation of concerns between client and server contexts.

Server routes do not fully support dynamic routes

Server routes currently do not support the full functionality of dynamic routes as pages do. This is a known limitation.

Legacy middleware and handlers support

Use fromNodeMiddleware to wrap legacy Express-style middleware and handlers. Example for handler: export default fromNodeMiddleware((req, res) => { res.end('Legacy handler') }). Example for middleware: export default fromNodeMiddleware((req, res, next) => { console.log('Legacy middleware'); next() }). Never combine next() callback with async legacy middleware or middleware returning a Promise.

Give your agent this brain