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 · Guide · all subjects

plugins & middleware

5 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 plugins are auto-registered from server/plugins directory

Nuxt automatically reads any files in the ~~/server/plugins directory and registers them as Nitro plugins. This allows extending Nitro's runtime behavior and hooking into lifecycle events. Plugins should export a default function created with `definePlugin()` from 'nitro'.

Example Nitro plugin

```ts import { definePlugin } from 'nitro' export default definePlugin((nitroApp) => { console.log('Nitro plugin', nitroApp) }) ``` This example shows a basic Nitro plugin. This file should be placed in server/plugins/nitroPlugin.ts.

Example server plugin with Redis storage

```ts import { definePlugin } from 'nitro' import redisDriver from 'unstorage/drivers/redis' export default definePlugin(() => { const storage = useStorage() // Dynamically pass in credentials from runtime configuration, or other sources const driver = redisDriver({ base: 'redis', host: useRuntimeConfig().redis.host, port: useRuntimeConfig().redis.port, }) // Mount driver storage.mount('redis', driver) }) ``` This example shows how to configure storage via a server plugin using runtime config. This file should be placed in server/plugins/storage.ts.

Page key and keep-alive configuration in Nuxt 3

In Nuxt 3, custom page keys and keep-alive props are set using definePageMeta. The syntax is: definePageMeta({ key: route => route.slug, keepalive: { exclude: ['modal'] } }).

definePageMeta for nested routes configuration

In Nuxt 3, use definePageMeta to configure nested routes with properties like key (computed from route), transition, and keepalive options, replacing the Nuxt 2 approach of passing props to <NuxtChild>.

Give your agent this brain