Skip to content

Overview

The module's surface is small: a handful of options in nuxt.config.ts, one function your scripts export, and one virtual module their results land in.

Configuration

Methods

Imported from nuxt-prepare/config in every prepare script:

ts
// `server.prepare.ts`
import { defineNuxtPrepareHandler } from 'nuxt-prepare/config'

export default defineNuxtPrepareHandler(async () => ({
  runtimeConfig: { public: { apiUrl: await resolveApiUrl() } },
  state: { buildRegion: 'eu-central-1' }
}))

A result carries ok, runtimeConfig, appConfig and state, each optional. defineNuxtPrepareHandler documents what each one does.

Virtual Module

Whatever your scripts returned as state is importable by key, typed from the value itself:

ts
import { buildRegion } from '#nuxt-prepare'
//     ^? "eu-central-1"

See Prepare State.

Released under the MIT License.