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

kit/compatibility

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

checkNuxtCompatibility constraints parameter

The constraints parameter is of type NuxtCompatibility with the following properties: | Property | Type | Required | Description | |----------|------|----------|-------------| | nuxt | string | false | Nuxt version in semver format. Versions may be defined in Node.js way, for example: >=2.15.0 <3.0.0 | | bridge | Record<string, string \| false> | false | Specifies version constraints or disables compatibility for specific Nuxt builders like vite, webpack, or rspack. Use false to disable. |

checkNuxtCompatibility usage example

import { checkNuxtCompatibility, defineNuxtModule } from '@nuxt/kit' export default defineNuxtModule({ async setup (_options, nuxt) { const issues = await checkNuxtCompatibility({ nuxt: '^2.16.0' }, nuxt) if (issues.length) { console.warn('Nuxt compatibility issues found:\n' + issues.toString()) } else { // do something } }, })

assertNuxtCompatibility function signature

assertNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<true>. Asserts that constraints are met for the current Nuxt version. If constraints are not met, throws an error with the list of issues as a string.

assertNuxtCompatibility parameters

The constraints parameter accepts the same properties as checkNuxtCompatibility (nuxt and bridge). The optional nuxt parameter is the Nuxt instance; if not provided, it will be retrieved from context via useNuxt() call.

hasNuxtCompatibility function signature

hasNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<boolean>. Checks if constraints are met for the current Nuxt version. Returns true if all constraints are met, otherwise returns false. For Nuxt 2, it also checks for bridge support.

hasNuxtCompatibility usage example

import { defineNuxtModule, hasNuxtCompatibility } from '@nuxt/kit' export default defineNuxtModule({ async setup (_options, nuxt) { const usingNewPostcss = await hasNuxtCompatibility({ nuxt: '^2.16.0' }, nuxt) if (usingNewPostcss) { // do something } else { // do something else } }, })

isNuxtMajorVersion function signature

isNuxtMajorVersion(major: number, nuxt?: Nuxt): boolean. Checks if the current Nuxt instance is of the specified major version. The major parameter specifies which major version to check against. The optional nuxt parameter is the Nuxt instance; if not provided, it will be retrieved from context via useNuxt() call.

isNuxtMajorVersion usage example

import { defineNuxtModule, isNuxtMajorVersion } from '@nuxt/kit' export default defineNuxtModule({ setup () { if (isNuxtMajorVersion(3)) { // do something for Nuxt 3 } else { // do something else for other versions } }, })

isNuxt3 function signature

isNuxt3(nuxt?: Nuxt): boolean. Checks if the current Nuxt version is 3.x. The optional nuxt parameter is the Nuxt instance; if not provided, it will be retrieved from context via useNuxt() call.

isNuxt2 function signature

isNuxt2(nuxt?: Nuxt): boolean. Checks if the current Nuxt version is 2.x. The optional nuxt parameter is the Nuxt instance; if not provided, it will be retrieved from context via useNuxt() call.

isNuxt2 deprecation notice

isNuxt2 may be removed in @nuxt/kit v5 or a future major version. Use isNuxtMajorVersion(2, nuxt) instead.

getNuxtVersion function signature

getNuxtVersion(nuxt?: Nuxt): string. Returns the current Nuxt version as a string. The optional nuxt parameter is the Nuxt instance; if not provided, it will be retrieved from context via useNuxt() call.

Give your agent this brain