Module Configuration
Introduction
Movk Nuxt uses movk as the configuration key in nuxt.config.ts:
Prefix
- Type:
string - Default:
'M'
Component prefix, used to avoid naming conflicts with other component libraries.
export default defineNuxtConfig({
movk: {
prefix: 'My' // Components become MyAutoForm, MyDatePicker, etc.
}
})
Theme
The theme module centrally manages colors, radius, icon sets and fonts. The first three provide options to the ThemePicker component and useTheme composable, while the font is injected at build time. All fields are configured under movk.theme.
ThemePicker component.export default defineNuxtConfig({
movk: {
theme: {
enabled: true
}
}
})
appConfig defaults, theme plugin, ThemePicker component registration). Defaults to true. When disabled, ThemePicker is no longer registered.@nuxt/ui's theme.colors. Defaults to ['primary', 'secondary', 'success', 'info', 'warning', 'error'].@nuxt/ui's theme.defaultVariants.@nuxt/ui's theme.prefix. For example 'tw'.'Alibaba PuHuiTi', 'OPPO Sans') and the module injects the stylesheet, a preconnect and a --font-sans carrying the Chinese fallback stack at build time; for self-hosted fonts use the { name, href } form to supply the stylesheet URL. When omitted, --font-sans is not injected and the font is controlled entirely by your project's CSS @theme.font-family declared by @font-face in the stylesheet character for character.'/fonts/my-font.css'. Optional for built-in fonts. A font that is neither built in nor given this field triggers no request at all.--ui-radius is not injected and the @nuxt/ui default or your project CSS applies. For example 0.5.ThemePicker radius options (in rem). Defaults to [0, 0.125, 0.25, 0.375, 0.5].ThemePicker neutral color options.Custom Font
export default defineNuxtConfig({
movk: {
theme: {
// Built-in fonts only need the name
font: 'Alibaba PuHuiTi'
// Self-hosted fonts supply the entry CSS URL
// font: { name: 'My Font', href: '/fonts/my-font.css' }
}
}
})
Icon
Controls whether the module's own icons enter the @nuxt/icon build-time bundle.
export default defineNuxtConfig({
movk: {
icon: {
clientBundle: true
}
}
})
true. When disabled, those icons are fetched on demand at runtime.API
The API system provides complete request wrapping and auth management, configured via the api option.
Basic Configuration
export default defineNuxtConfig({
movk: {
api: {
// Whether to enable API functionality
enabled: true,
// Default endpoint name
defaultEndpoint: 'default',
// Whether to enable debug mode
debug: false
}
}
})
true.'default'.false.endpoints
Supports configuring multiple API endpoints, each with its own independent configuration:
export default defineNuxtConfig({
movk: {
api: {
endpoints: {
// Default endpoint
default: {
baseURL: '/api'
},
// Admin endpoint
admin: {
baseURL: '/admin-api',
auth: {
tokenType: 'Bearer'
}
},
// Third-party API
external: {
baseURL: 'https://api.example.com',
// Injected on the server only
headers: {
'X-Secret-Key': process.env.EXTERNAL_SECRET_KEY
},
// Injected on both server and client
publicHeaders: {
'X-Api-Version': '2'
}
}
}
}
}
})
Endpoint Options
headers. Use for non-secret constant headers only.auth
Configure automatic auth behavior, integrated with nuxt-auth-utils:
nuxt-auth-utils when auth.enabled is true and tokenSource is 'session'. To use useUserSession on its own, add nuxt-auth-utils to modules.With nuxt-auth-utils v0.6, set NUXT_APP_SECRET to a value of at least 32 characters in production. Generate one with openssl rand -base64 32. In development, Nuxt generates a secret if the variable is unset.When upgrading from v0.5, remove NUXT_SESSION_PASSWORD and runtimeConfig.session.password. Signed-in users will need to sign in again once after the upgrade. Migration guideexport default defineNuxtConfig({
movk: {
api: {
auth: {
// Enable auth
enabled: true,
// Token source
tokenSource: 'session',
// Path to token in session
sessionTokenPath: 'user.accessToken',
// Token type
tokenType: 'Bearer',
// Header name
headerName: 'Authorization',
// 401 unauthorized handling config
unauthorized: {
// Redirect to login page on 401
redirect: true,
loginPath: '/login',
// Clear session on 401
clearSession: true
}
}
}
}
})
When calling a third-party API directly from the browser, put the credential in runtimeConfig.public and point at it:
export default defineNuxtConfig({
runtimeConfig: {
public: {
llmApiKey: ''
}
},
movk: {
api: {
auth: {
enabled: true,
tokenSource: 'public-runtime-config',
tokenPath: 'llmApiKey',
tokenType: 'Bearer',
unauthorized: {
redirect: false
}
}
}
}
})
NUXT_PUBLIC_LLM_API_KEY=your-api-key
public-runtime-config and publicHeaders are shipped to the browser along with the page, and any visitor can read them. Use them only when the credential is designed to be public, or its scope is narrow enough to accept the exposure. Account-level keys belong behind a server-side proxy.Auth Options
false.'session' retrieves it from the nuxt-auth-utils session; 'public-runtime-config' retrieves it from runtimeConfig.public, for credentials that are meant to be exposed in the browser. Defaults to 'session'.'token' maps to session.token, 'user.token' maps to session.user.token. Defaults to 'token'.runtimeConfig.public, dot-notation supported. Only applies when tokenSource is 'public-runtime-config'. Defaults to 'apiToken'.'Bearer'.tokenType is 'Custom'.'Authorization'.true.'/login'.true.response
Configure API response parsing rules, including business status code determination, data unwrapping fields and message extraction:
export default defineNuxtConfig({
movk: {
api: {
response: {
// Successful status code list
successCodes: [200, 0],
// Status code field name
codeKey: 'code',
// Message field name
messageKey: 'message',
// Data field name
dataKey: 'data',
// Whether to validate the business status code
businessCheck: true,
// Whether to unwrap by dataKey
unwrap: true
}
}
}
})
An endpoint-level response overrides the global one. Endpoints returning a bare array or object turn off checking and unwrapping; explicit per-request businessCheck / unwrap values can still override:
export default defineNuxtConfig({
movk: {
api: {
endpoints: {
sensor: {
baseURL: 'https://sensor.example.com',
response: { businessCheck: false, unwrap: false }
}
}
}
}
})
Response Configuration Options
code value in the response is considered successful if it is in this list. Defaults to [200, 0].'code'.'message'.'data'.successCodes; when off, any 2xx response is a success. Defaults to true.dataKey; when off, callers receive the raw response body. Defaults to true.toast
Configure global Toast notification behavior:
export default defineNuxtConfig({
movk: {
api: {
toast: {
// Enable notifications globally
enabled: true,
// Success notification config
success: {
show: true,
color: 'success',
duration: 3000,
// Only notify on mutating requests, stay quiet on GET
methods: ['POST', 'PUT', 'PATCH', 'DELETE']
},
// Error notification config
error: {
show: true,
color: 'error',
duration: 3000
}
}
}
}
})
Toast Options
true.show: false disables it; methods restricts it to the listed HTTP methods (case-insensitive), and omitting the field means no restriction.show: false disables it; methods works the same way, and is usually left unset so errors surface on every method.enabled, show and methods are all global-level switches that a single request can override. Precedence: request-level show > request-level successMessage / errorMessage > global success.show / error.show / methods > global enabled. So when a toast is globally disabled or the method misses the whitelist, both toast: { success: { show: true } } and toast: { successMessage: 'Saved' } still show it.methods only belongs in the global or endpoint config — a single request has exactly one method, so request-level toast does not accept the field. An endpoint-level methods replaces the global one instead of merging the arrays.Configuration Priority
Configuration is merged in the following priority order (later overrides earlier):
- Module built-in defaults - Default config defined in
api-defaults.ts - Global config -
movk.api.auth,movk.api.toast,movk.api.response - Endpoint config -
movk.api.endpoints[name].auth, etc. - Request-level config -
toastoption inuseApiFetch, etc.
// Example: request-level config overrides global config
const { data } = await useApiFetch('/users', {
toast: {
successMessage: 'Fetched successfully', // Overrides global config
error: false // Disable error notifications
}
})
Request headers are layered in the following order (later overrides earlier):
- Endpoint
publicHeaders- Injected on both server and client - Endpoint
headers- Injected on the server only, overrides matchingpublicHeaderskeys - Request-level
headers- Passed to$apioruseApiFetch - Auth injection - Written by the
onRequestinterceptor underheaderName, highest priority
Component and Validation Locale
Set the locale on UApp to change component text. Use extendMovkLocale(locale, overrides) to override individual messages and useMovkLocale() to read the active locale code and translator.
export default defineNuxtConfig({
movk: { zod: { locale: 'auto', fallback: 'en', locales: ['en', 'zh-CN'] } }
})
movk.zod configures the global validation locale and required messages. With auto, AutoForm and SearchForm follow UApp on the client and use fallback on the server. Set customError through movk:zod:config to customize those forms in the current Nuxt application. In Vue + Vite pass { zod: { customError } } to the Vue plugin. Direct Zod validation uses the configured global locale or fallback.
Environment Variables
For sensitive configuration (such as API keys), use environment variables:
export default defineNuxtConfig({
movk: {
api: {
endpoints: {
external: {
baseURL: process.env.EXTERNAL_API_URL,
headers: {
'X-API-Key': process.env.EXTERNAL_API_KEY
}
}
}
}
}
})
EXTERNAL_API_URL=https://api.example.com
EXTERNAL_API_KEY=your-api-key