Registry / web-framework / vite-plugin-mkcert

vite-plugin-mkcert

JSON →
library2.0.0jsnpmunverified

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.

npm install vite-plugin-mkcert
INSTALL
IMPORT
SIG · VITE-PLUGIN-MKCERT
V
vite-plugin-mkcert
web-frameworkjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mkcert
import mkcert from 'vite-plugin-mkcert'
const mkcert = require('vite-plugin-mkcert')
ESM-only since v2.0.0; default export.
mkcert (default)
import mkcert from 'vite-plugin-mkcert'
import { mkcert } from 'vite-plugin-mkcert'
The package exports a single function as default. Named import will fail.
type import
import type { Options } from 'vite-plugin-mkcert'
TypeScript types are included; Options interface for plugin configuration.

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()] });
Debug
Known issues
breakingv2.0.0 drops support for Node.js < 22.19.0
fix
Upgrade Node.js to >=22.19.0
affects: >=2.0.0
breakingv2.0.0 is ESM-only; require() will fail
fix
Use import or dynamic import() instead of require()
affects: >=2.0.0
breakingv1.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)
affects: >=1.17.12
deprecatedv1.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
affects: >=1.0.0 <2.0.0
gotchaPlugin downloads mkcert binary from GitHub; network restrictions may fail
fix
Set source: 'coding' for Chinese mirror, or provide mkcertPath to a local binary
affects: all
gotchaParentheses 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
affects: <1.17.4
Errors
Common errors & fixes
Error: spawn mkcert ENOENT
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 [ERR_REQUIRE_ESM]: require() of ES Module not supported
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: unable to get local issuer certificate
Root CA not trusted by the system
fix
Run 'mkcert -install' or let the plugin automatically install the CA (requires admin/sudo)
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
viterequiredpeer dependency; the plugin hooks into Vite's dev server to inject HTTPS certificates
Agent activity
51 hits · last 30 days
node
46
OpenAI (training)
1
Resources
vite-plugin-mkcert — npm install vite-plugin-mkcert · libregistry