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

migration/plugins

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

Nuxt 3 plugin format and defineNuxtPlugin

Nuxt 3 plugins accept only one argument: nuxtApp. Plugins must use the defineNuxtPlugin helper function. To make things available in the plugin, call nuxtApp.provide() with a key and value, or return an object with a provide property containing the items to expose. Both approaches work; the return object format provides automatic type support.

Nuxt 3 automatic plugin registration

All files in the app/plugins/ folder at the top level, and any index files in subdirectories, are automatically registered. Remove entries from the nuxt.config plugins array for files in app/plugins/. To specify client-only or server-only loading, use the file name convention: plugins/my-plugin.client.ts loads only on client-side, and plugins/my-plugin.server.ts loads only on server-side.

Example: Nuxt 2 to Nuxt 3 plugin migration

Nuxt 2 plugin: export default (ctx, inject) => { inject('injected', () => 'my injected function') } Nuxt 3 equivalent using nuxtApp.provide(): export default defineNuxtPlugin((nuxtApp) => { nuxtApp.provide('injected', () => 'my injected function') }) Nuxt 3 equivalent using return object: export default defineNuxtPlugin((nuxtApp) => { return { provide: { injected: () => 'my injected function' } } })

callHook no longer always async in Nuxt 5

With Nuxt 5, `callHook` may return `void` instead of always returning `Promise<void>`. This is a performance improvement that avoids unnecessary Promise allocations. With `compatibilityVersion: 4`, Nuxt wraps `callHook` with `Promise.resolve()` for backward compatibility. Replace `.then()` and `.catch()` chaining with `await`: change `callHook('my:hook').then(() => {})` to `await callHook('my:hook')` and `callHook('my:hook').catch(err => {})` to `try { await callHook('my:hook') } catch (err) {}`. Set `experimental.asyncCallHook: true` to ensure callHook always returns a Promise.

Give your agent this brain