vite-plugin-mkcert

raw JSON →
2.0.0 verified Mon Apr 27 auth: no javascript

Vite plugin that uses mkcert to automatically generate and trust locally valid HTTPS certificates for Vite's dev server. Current stable version is v2.0.0 (2026-04-09). Release cadence is frequent with several minor/patch versions per year. Key differentiators: zero-config setup, automatic local IP hosts, support for mobile device trust instructions, and a built-in mkcert binary downloader. Since v1.17.12, it replaced axios with native fetch, removing a long-standing supply chain risk. v2.0.0 requires Node.js >= 22.19.0 and Vite >= 3. Compared to alternatives like @vitejs/plugin-basic-ssl, this plugin provides a proper local CA that works across browsers and avoids browser security warnings.

error Error: spawn mkcert ENOENT
cause mkcert binary not installed or not found in PATH
fix
Install mkcert manually or ensure the plugin can download it (check network/proxy settings)
error Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
cause Using require() on an ESM-only package (v2+)
fix
Change to import mkcert from 'vite-plugin-mkcert' and ensure your project is ESM via "type": "module" in package.json
error Error: unable to get local issuer certificate
cause Root CA not trusted by the system
fix
Run 'mkcert -install' or let the plugin automatically install the CA (requires admin/sudo)
breaking v2.0.0 drops support for Node.js < 22.19.0
fix Upgrade Node.js to >=22.19.0
breaking v2.0.0 is ESM-only; require() will fail
fix Use import or dynamic import() instead of require()
breaking v1.17.12 replaced axios with native fetch; proxy configuration changed
fix If you relied on axios-specific proxy options, switch to the new proxy option or environment variables (HTTPS_PROXY, HTTP_PROXY)
deprecated v1.x required server.https setting; Vite 5+ defaults to https when plugin is present
fix With Vite 5+, you can omit server: { https: true } and just use the plugin
gotcha Plugin downloads mkcert binary from GitHub; network restrictions may fail
fix Set source: 'coding' for Chinese mirror, or provide mkcertPath to a local binary
gotcha Parentheses in the project folder path cause mkcert command to fail
fix Upgrade to v1.17.4+ which fixes path escaping, or avoid parentheses in folder names
npm install vite-plugin-mkcert
yarn add vite-plugin-mkcert
pnpm add vite-plugin-mkcert

Basic setup of vite-plugin-mkcert with Vite. Enables HTTPS dev server and auto-generates trusted certificates.

import { defineConfig } from 'vite';
import mkcert from 'vite-plugin-mkcert';

export default defineConfig({
  server: { https: true },
  plugins: [mkcert()]
});