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

composables/context

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

useNuxt returns object with options property

The useNuxt function returns a Nuxt instance that includes an 'options' property of type NuxtOptions, which contains the resolved Nuxt configuration.

useNuxt returns object with hooks property

The useNuxt function returns a Nuxt instance that includes a 'hooks' property of type Hookable<NuxtHooks>, which is the Nuxt hook system that allows registering and listening to lifecycle events.

useNuxt returns object with callHook method

The useNuxt function returns a Nuxt instance that includes a 'callHook' method with signature (name: string, ...args: any[]) => Promise<any>. This is a shortcut for nuxt.hooks.callHook that triggers a lifecycle hook manually and runs all registered callbacks.

useNuxt returns object with addHooks method

The useNuxt function returns a Nuxt instance that includes an 'addHooks' method with signature (configHooks: NestedHooks) => () => void. This is a shortcut for nuxt.hooks.addHooks that registers multiple hooks at once.

tryUseNuxt function signature and return type

The tryUseNuxt function from @nuxt/kit returns the Nuxt instance or null. It has the signature: function tryUseNuxt(): Nuxt | null. It returns null if Nuxt is not available, rather than throwing an error.

useNuxt and tryUseNuxt usage context

When working with the setup function in Nuxt modules, Nuxt is already provided as the second argument to the setup function, so you can access it directly without needing to call useNuxt() or tryUseNuxt().

useNuxt example accessing builder configuration

Example showing useNuxt usage: import { useNuxt } from '@nuxt/kit'; export const setupTranspilation = () => { const nuxt = useNuxt(); if (nuxt.options.builder === '@nuxt/webpack-builder') { nuxt.options.build.transpile ||= []; nuxt.options.build.transpile.push('xstate'); } };

tryUseNuxt example with null check

Example showing tryUseNuxt usage: import { tryUseNuxt } from '@nuxt/kit'; export const requireSiteConfig = (): SiteConfig => { const nuxt = tryUseNuxt(); if (!nuxt) { return {}; } return nuxt.options.siteConfig; };

Give your agent this brain