# vite-plugin-mkcert

> Provide certificates for vite's https dev service

Latest version **2.1.0** (published 2026-06-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install vite-plugin-mkcert
pnpm add vite-plugin-mkcert
yarn add vite-plugin-mkcert
bun add vite-plugin-mkcert
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2026-06-03 |
| First published | 2021-05-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.19.0 |
| Dependencies | 3 |
| Unpacked size | 87.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 770 |
| Author | liuweigl |
| Maintainers | liuweigl |
| Keywords | vite-plugin, certificate, https, mkcert |

## Links

- npm: https://www.npmjs.com/package/vite-plugin-mkcert
- Repository: https://github.com/liuweiGL/vite-plugin-mkcert
- Homepage: https://github.com/liuweiGL/vite-plugin-mkcert#readme
- Issues: https://github.com/liuweiGL/vite-plugin-mkcert/issues
- npm.io page: https://npm.io/package/vite-plugin-mkcert

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^4.4.3
- [undici](https://npm.io/package/undici.md) ^8.3.0
- [supports-color](https://npm.io/package/supports-color.md) ^10.2.2

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 2.1.0 (latest) — 2026-06-03
- 2.0.0 — 2026-04-09
- 1.17.12 — 2026-04-09
- 1.17.10 — 2026-02-25
- 1.17.9 — 2025-10-07
- 1.17.8 — 2025-03-14
- 1.17.7 — 2025-02-28
- 1.17.6 — 2024-08-15
- 1.17.5 — 2024-03-20
- 1.17.4 — 2024-02-27
- 1.17.3 — 2024-01-18
- 1.17.2 — 2024-01-09
- 1.17.1 — 2023-11-20
- 1.17.0 — 2023-11-20
- 1.16.0 — 2023-06-28
- … 38 more at https://npm.io/package/vite-plugin-mkcert/versions

## README

# [中文文档](README-zh_CN.md)

# vite-plugin-mkcert 

![Vite compatibility](https://registry.vite.dev/api/badges?package=vite-plugin-mkcert&tool=vite)


Use mkcert to provide certificate support for vite https development services.

## When should I use this plugin

1. When you want to use `http/2` to solve the concurrency limit of vite http dev server requests, you find that the browser cache is invalid [#2725](https://github.com/vitejs/vite/issues/2725).
2. I have obsessive-compulsive disorder, and I hope that the browser will not show annoying https certificate errors.

## Effect

<details>
   <summary>View</summary>
   
   ![localhost](docs/assets/screenshot/localhost.png)

   ![127.0.0.1](docs/assets/screenshot/127.0.0.1.png)

   ![localhost](docs/assets/screenshot/localip.png)
</details>

## Quick start

### Requirements

- Node.js >= 22.19.0

1. Installation dependencies

```sh
yarn add vite-plugin-mkcert -D
```

2. Configure vite

```ts
import {defineConfig} from 'vite'
import mkcert from 'vite-plugin-mkcert'

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    https: true
  }, // Not needed for Vite 5+ (simply omit this option)
  plugins: [mkcert()]
})
```

## Parameters
### hosts

Custom hosts, default value is `localhost` + `local ip addrs`.
### force

Whether to force generate.
### autoUpgrade

Whether to automatically upgrade `mkcert`.

### source

Specify the download source of `mkcert`, domestic users can set it to `coding` to download from the coding.net mirror, or provide a custom [BaseSource](plugin/mkcert/Source.ts).

### mkcertPath

If the network is restricted, you can specify a local `mkcert` file instead of downloading from the network.

### proxy

Proxy URL used when downloading the `mkcert` binary.

Example: `http://127.0.0.1:7890`

If not provided, it will fallback to environment variables: `HTTPS_PROXY`, `https_proxy`, `HTTP_PROXY`, `http_proxy`.

### savePath

The location to save the files, such as the downloaded mkcert program and the generated CA file, private key and certificate file, etc. Default value is [PLUGIN_DATA_DIR](plugin/lib/constant.ts)

### keyFileName

The name of private key file generated by mkcert

### certFileName

The name of cert file generated by mkcert

## Mobile devices

For the certificates to be trusted on mobile devices, you will have to install the root CA. It's the `rootCA.pem` file in the folder printed by `mkcert -CAROOT`.

On iOS, you can either use AirDrop, email the CA to yourself, or serve it from an HTTP server. After opening it, you need to [install the profile in Settings > Profile Downloaded](https://github.com/FiloSottile/mkcert/issues/233#issuecomment-690110809) and then [enable full trust in it](https://support.apple.com/en-nz/HT204477).

For Android, you will have to install the CA and then enable user roots in the development build of your app. See [this StackOverflow answer](https://stackoverflow.com/a/22040887/749014).

## Display the debugging information of the plug-in

Set the environment variable `DEBUG`=`vite:plugin:mkcert`

## CHANGELOG

[CHANGELOG](CHANGELOG.md)

## Principle

Use [mkcert](https://github.com/FiloSottile/mkcert) to install the local `CA` certificate and generate it for [server.https](https://vitejs.bootcss.com/config/#server-https) Server certificate.

## Friendly reminder

1. Uninstall the `CA` certificate: `mkcert -uninstall`

## Thanks

- [mkcert](https://github.com/FiloSottile/mkcert)
- [daquinoaldo/https-localhost](https://github.com/daquinoaldo/https-localhost)

---
_Source: https://npm.io/package/vite-plugin-mkcert · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
