The `nuxt-vite-legacy` module integrates `@vitejs/plugin-legacy` into Nuxt 3 applications, enabling support for older web browsers that do not fully adhere to modern JavaScript standards, specifically those lacking `<script type="module">` support. It provides polyfills and a separate legacy bundle, addressing a gap that the core Nuxt team opted not to address directly. The current stable version is 2.0.1, which proactively supports Vite v7. This package maintains an irregular release cadence, typically updating to align with major or minor releases of Nuxt and Vite. Its primary differentiator is offering a practical solution for targeting very old browsers, which is not an out-of-the-box feature in modern Nuxt applications.
npm install nuxt-vite-legacyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install `nuxt-vite-legacy` and configure it in your `nuxt.config.ts` to target specific legacy browsers like Chrome 49, including additional polyfills.
Upgrade your Nuxt application to Nuxt 3.15+ and Vite 6+. Ensure all related dependencies are also compatible with these versions.
For comprehensive support in browsers that support `<script type="module">` but lack modern features, manual implementation of feature detection or further polyfilling might be required, or consider contributing to the module to add the missing detection scripts.
Always install `nuxt-vite-legacy` along with the recommended Nuxt and Vite versions specified in its release notes. If issues arise after an upgrade, verify the compatibility of all three packages. Consider reviewing the module's GitHub issues for reported version mismatches.
Run `npm install nuxt-vite-legacy --save-dev` or `pnpm add nuxt-vite-legacy --save-dev` and ensure it's listed in the `modules` array as a string: `modules: ["nuxt-vite-legacy"]`.
Ensure `nuxt-vite-legacy` is installed and added to `modules` in `nuxt.config.ts`. Verify that your `legacy` configuration block includes valid `targets`.
Review the 'Caveats' section in the documentation. Ensure your `legacy.targets` configuration correctly identifies the problematic browsers. If using SSR, confirm the server-side rendering logic correctly identifies and serves the legacy bundle based on browser capabilities (though this module has known limitations here).