Skip to content

Configuration ​

The module is configured under the we key of nuxt.config.ts. Every option is optional: the values below are the defaults.

ts
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@weconstudio/nuxt', 'vuetify-nuxt-module'],

  we: {
    host: 'localhost',
    bus: { enabled: true, optionsApi: true },
    notify: { enabled: true, css: true, optionsApi: true },
    portal: { enabled: true },
    form: { enabled: true, formValidatorMixin: true },
    api: {
      baseUrl: '',
      apiSuffix: 'api',
      endpoints: [],
    },
    gen: true,
    html: { addTags: [], addAttributes: [], forbidTags: [], forbidAttributes: [] },
  },
})

The resolved options are also exposed at runtime as useRuntimeConfig().public.we.

Options ​

OptionTypeDefaultDescription
hoststring'localhost'Host used for the "Listening" URL printed in the dev server console (together with the /gen URL).
bus.enabledbooleantrueAuto-imports useBus.
bus.optionsApibooleantrueProvides this.$bus (see Options API). Requires bus.enabled.
notify.enabledbooleantrueAuto-imports useNotify and keeps notivue/nuxt enabled.
notify.cssboolean | string[]truetrue adds notivue/notification.css and notivue/animations.css to css; an array adds those paths instead; false adds nothing.
notify.optionsApibooleantrueProvides this.$notify. Requires notify.enabled.
portal.enabledbooleantrueInstalls portal-vue (<portal> / <portal-target>), used by the form actions and titles.
form.enabledbooleantrueAuto-imports useForm, useFormWrapper, useValidators and useServerErrors.
form.formValidatorMixinbooleantrueAuto-imports the legacy formValidatorMixin. Requires form.enabled.
api.baseUrlstring''Base URL of the backend. When empty, the first entry of endpoints is used.
api.apiSuffixstring'api'Path appended to the base URL: the API URL is ${baseUrl}/${apiSuffix}, so omit leading and trailing slashes.
api.endpointsstring[][]Base URLs selectable at runtime with WeEndpointSwitcher / useApiUrl.
genbooleantrueAdds the generator page at /gen. Only in development.
html.addTagsstring[][]Extra tags allowed by WeHtml / useHtmlSanitizer.
html.addAttributesstring[][]Extra attributes allowed by the sanitizer.
html.forbidTagsstring[][]Tags removed from the default allow-list.
html.forbidAttributesstring[][]Attributes removed from the default allow-list.

TIP

Options are merged with the defaults, so arrays are concatenated rather than replaced. This is why html only accepts additions and exclusions instead of a full allow-list.

Always registered ​

Independently of the flags above, the module always registers:

App config ​

Datatable defaults live in app.config.ts under we.datatables. A prop set on a single WeDatatable wins over these values.

ts
// app.config.ts
import { markRaw } from 'vue'
import MyFormatter from '~/components/MyFormatter.vue'

export default defineAppConfig({
  we: {
    datatables: {
      persist: 'local',
      persistColumns: 'local',
      itemsPerPage: 25,
      formatters: {
        my_formatter: markRaw(MyFormatter),
      },
    },
  },
})
KeyTypeDefaultDescription
persist'state' | 'local' | 'session''state'Where the table state (search, page, filters, items per page, sorting) is kept: Nuxt state, localStorage or sessionStorage.
persistColumns'state' | 'local' | 'session''local'Where the selected columns are kept.
itemsPerPagenumber—Default items per page.
formattersRecord<string, Component>—Extra cell formatters, merged over the built-in ones and matched by the field's formatter or type.

Runtime hooks ​

useApi calls these Nuxt runtime hooks on every request, with the ofetch context:

HookArgument
we-api:onRequestFetchContext
we-api:onRequestErrorFetchContext & { error: Error }
we-api:onResponseFetchContext & { response: FetchResponse }
we-api:onResponseErrorFetchContext & { response: FetchResponse }

The hooks are not awaited, so keep handlers synchronous when they change the request.

ts
// plugins/api-locale.ts
export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.hook('we-api:onRequest', (context) => {
    context.options.headers.set('Accept-Language', nuxtApp.$i18n.locale.value)
  })

  nuxtApp.hook('we-api:onResponseError', ({ response }) => {
    console.warn('API error', response.status)
  })
})

Other settings ​

  • Dates: vue-lux is configured with its own top-level lux key, not we.lux. See date formatting.
  • Bundled modules: i18n, icon, Sanctum and notivue keep their own config keys, see Getting started.
  • Vite dedupe: the module adds vue, vuetify and (when notify is enabled) notivue to vite.resolve.dedupe, so a single copy of each is bundled.
  • SBOM: building with BUNDLE_SBOM=true (production builds only) adds rollup-plugin-sbom and writes a CycloneDX SBOM of the client bundle (cyclonedx/bom.json).

Source Code ​