Nuxe bundles a Nitro-powered server alongside your Vue application. Any file you place insideDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/dvlkit/nuxe/llms.txt
Use this file to discover all available pages before exploring further.
server/api/ becomes an HTTP endpoint served under the /api prefix. There is no router configuration to write — the file name determines both the URL path and the accepted HTTP method.
File naming conventions
Encode the HTTP method as a suffix before the file extension. When no suffix is present the handler responds to all methods.| File | Method | URL |
|---|---|---|
server/api/ping.get.ts | GET | /api/ping |
server/api/users.post.ts | POST | /api/users |
server/api/users/[id].delete.ts | DELETE | /api/users/:id |
server/api/health.ts | All methods | /api/health |
.get, .post, .put, .patch, .delete, .head, and .options.
The default API prefix is
/api. You can change it by setting server.apiPrefix in nuxe.config.ts.Writing a route handler
Every handler exports a default function wrapped indefineEventHandler. The function receives an H3Event and returns any JSON-serialisable value (or a Response for full control).
The playground’s ping.get.ts shows a complete, realistic example — reading query parameters, simulating delay, and returning different status codes based on the request:
whoami.get.ts handler demonstrates returning a structured object — Nuxe serialises it to JSON automatically:
Available h3 utilities
Import everything you need from@dvlkit/nuxe/server. These are all thin re-exports of the upstream h3 library.
Request reading
getQuery · getRouterParam · readBody · getHeader · getRequestURL · getMethodResponse writing
setResponseStatus · setHeader · sendRedirectCookies
getCookie · setCookie · deleteCookie · parseCookiesError handling
createError — creates an h3 error with status code and messageRequest utilities
Returns the parsed query string as a plain object. All values are
string | string[].Returns a single dynamic path parameter. For a route file named
[id].get.ts, call getRouterParam(event, 'id').Reads and JSON-parses the request body. Returns a
Promise that resolves to the parsed value.Returns the value of a request header, or
undefined if absent.Returns a
URL object for the full request URL, including protocol and host.Returns the HTTP method string in uppercase, e.g.
'GET' or 'POST'.Response utilities
Sets the HTTP status code for the response. Call before returning the response body.
Sets a single response header.
Sends an HTTP redirect response.
code defaults to 302.Creates an h3 error. Throw this to abort the handler and return an error response with the given status code.
Cookie utilities
Returns the value of a single cookie from the request.
Sets a
Set-Cookie header on the response.Clears a cookie by setting its expiry to the past.
Returns all request cookies as a
Record<string, string>.TypeScript types
@dvlkit/nuxe/server also exports the following h3 TypeScript types for annotating your handlers:
| Type | Description |
|---|---|
H3Event | The event object passed to every defineEventHandler callback |
H3EventContext | The event.context record for attaching request-scoped data |
EventHandler | The function signature returned by defineEventHandler |
Runtime config in server routes
useRuntimeConfig() works inside server API handlers the same way it does in Vue components. Values under the public key are safe to return to clients; private keys (defined at the top level of runtimeConfig) are server-only:
Custom request logging
Place anuxe-request-logger.ts file at the project root to intercept every request before it reaches your route handlers. The file receives the Nitro app instance and wraps its fetch method: