Programmatic usage can be helpful when you want to use Nuxt programmatically, for example, when building a CLI tool or test utils.
loadNuxtLoad Nuxt programmatically. It will load the Nuxt configuration, instantiate and return the promise with Nuxt instance.
function loadNuxt (loadOptions?: LoadNuxtOptions): Promise<Nuxt>
loadOptions: Loading conditions for Nuxt. loadNuxt uses c12 under the hood, so it accepts the same options as c12.loadConfig with some additional options:
| Property | Type | Required | Description |
|---|---|---|---|
dev | boolean | false | If set to true, Nuxt will be loaded in development mode. |
ready | boolean | true | If set to true, Nuxt will be ready to use after the loadNuxt call. If set to false, you will need to call nuxt.ready() to make sure Nuxt is ready to use. |
buildNuxtBuild Nuxt programmatically. It will invoke the builder (currently @nuxt/vite-builder or @nuxt/webpack-builder) to bundle the application.
function buildNuxt (nuxt: Nuxt): Promise<any>
nuxt: Nuxt instance to build. It can be retrieved from the context via useNuxt() call.
loadNuxtConfigLoad Nuxt configuration. It will return the promise with the configuration object.
function loadNuxtConfig (options: LoadNuxtConfigOptions): Promise<NuxtOptions>
options: Options to pass in c12 loadConfig call.
writeTypesGenerates tsconfig.json and writes it to the project buildDir.
function writeTypes (nuxt?: Nuxt): void
nuxt: Nuxt instance to build. It can be retrieved from the context via useNuxt() call.