new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Nuxt · Getting started · all subjects

server-engine

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

Nitro server engine for backend capabilities

Nuxt uses Nitro as its server engine to unlock full-stack capabilities. Nitro automatically generates server APIs by reading files from server/api/ directory and server middleware from server/middleware/ directory.

Nitro development and production behavior

In development, Nitro uses Rollup and Node.js workers for server code with context isolation. In production, Nitro builds the app and server into one universal .output directory that is minified, free of Node.js modules (except polyfills), and deployable to Node.js, Serverless, Workers, Edge-side rendering, or static environments.

Nuxt server is powered by Nitro

Nuxt's server framework is Nitro, which was originally created for Nuxt but is now part of UnJS and open for other frameworks. It can even be used independently. Nitro internally uses h3, a minimal HTTP framework built for high performance and portability.

Nitro superpowers in Nuxt

Using Nitro gives Nuxt full control of the server-side part of the app, universal deployment on any provider with many zero-config options, and hybrid rendering capabilities.

Define server endpoints and middleware with defineEventHandler

Server endpoints and middleware are defined using defineEventHandler from nitro/h3. They can be placed in files like server/api/test.ts. The handler receives an event parameter and can directly return text, json, html, or a stream. Hot module replacement and auto-import are supported out-of-the-box.

Server endpoint example with defineEventHandler

```ts import { defineEventHandler } from 'nitro/h3' export default defineEventHandler(async (event) => { // ... Do whatever you want here }) ``` This shows the basic structure for defining a server endpoint or middleware in Nuxt.

Server architecture changes in Nuxt 3

Nuxt 3 moves from a runtime Nuxt dependency to a minimal, standalone server compiled with nitropack.

Nuxt 3 built app has no runtime Nuxt dependency

In a built Nuxt 3 application, there is no runtime Nuxt dependency. This means the site will be highly performant and ultra-slim. However, you can no longer hook into runtime Nuxt server hooks.

Server API and middleware files auto-registered in Nuxt 3

In Nuxt 3, any files in the ~~/server/api and ~~/server/middleware directories will be automatically registered. You can remove them from your serverMiddleware array during migration.

Give your agent this brain