Skip to content

Plugin and runtime reference ​

Build entrypoints ​

Bundler entrypoints export the default matrix() factory; the Nuxt entrypoint exports a Module. See build tool integration for native/mixed setup, Electron scopes, and transform boundaries.

EntrypointHost
@xova/matrix/viteVite / electron-vite
@xova/matrix/nuxtNuxt Vite SSR / SPA Module
@xova/matrix/rollupRollup
@xova/matrix/webpackWebpack
@xova/matrix/esbuildesbuild

The default virtual module is virtual:matrix/runtime; with a scope it is virtual:matrix/runtime/<scope>. The build plugin implements these modules; they are not directly resolvable files in the npm package.

The Nuxt entrypoint exports a Module rather than a plugin factory. Register it in modules, optionally as ['@xova/matrix/nuxt', options]. It supports SSR applications and ssr: false SPA, shares one public build snapshot across client/server, defaults business exposure to ['VITE_', 'NUXT_PUBLIC_'], and automatically references declarations owned by Nuxt rootDir. Explicit envPrefix replaces that default; different original keys mapping to the same config field fail, even with equal values; type collection also checks aliases across products. It never maps or proxies runtimeConfig. See mixed Nuxt integration.

Plugin options ​

Pass these options to matrix() from the Vite, Rollup, Webpack, or esbuild entrypoint. They belong in the host configuration, not in matrix.config.ts.

OptionDefaultPurpose
envPrefixVITE_ outside Vite; Vite uses its resolved prefixString or string array of public prefixes. An explicit plugin option configures Vite's prefix too; MATRIX_ is always added. Prefixes control exposure, not whether values reach the child process.
scopeNo scopeModule/type isolation key, using only letters, digits, underscores, or hyphens. Use one scope per compilation.
inlinetrueReplace supported static reads with literals; false keeps only the immutable virtual runtime integration.
typesAutomatic with Matrix context, except in Vitestfalse disables generation; true or an object opts in, including in Vitest or without Matrix context. { output: '...' } selects a custom path.

Default behavior change: without Matrix CLI context, automatic generation leaves declarations untouched, creates no output directory, and warns once per plugin instance. Run the target through Matrix or use matrix prepare. Runtime configuration may be incomplete; opting into type generation does not restore missing context.

For shared-project declarations in Matrix CLI dev/build, see type preparation.

Relative output paths resolve from Vite's resolved root or other adapters' working directory. The default is .matrix/types/matrix-runtime.d.ts, or matrix-runtime-<scope>.d.ts in the same directory for scoped builds. Include custom outputs in the project's tsconfig.json.

For Nuxt, paths resolve from rootDir, not srcDir, and the Module handles type references, including custom outputs. project.typegen: false requires Module types: false for runtime-only mixed use; it does not disable virtual modules.

Runtime fields ​

FieldMeaning
environmentSelected Matrix configuration environment, such as staging or qa.
targetSelected Matrix target, such as build.
nodeEnvResolved Node process mode, distinct from the configuration environment.
isDevelopment, isProduction, isTestMode flags derived from nodeEnv.
variant, projectVariant and project keys for the build context.
productProduct key, id, name, slug, optional appId, and optional version.
configPublic environment fields with prefixes removed and names camel-cased; VITE_API_BASE becomes apiBase. Schema fields retain their declared scalar types.

Only expose values intended to be present in the application bundle. A schema does not make a secret safe to publish. Matrix does not replace the application framework's own environment system.