@vitejs/plugin-basic-ssl

A Vite plugin that generates a self-signed certificate so your dev and preview servers can run over HTTPS with zero setup.

Tool
npm
v2.3.0
515stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
69/100Good
Development Activity72
Maintenance60
Community48
Maturity56
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture80
Code Quality78
Innovation55
Learning Curve90

@vitejs/plugin-basic-ssl is an official Vite plugin that adds HTTPS support to Vite’s dev and preview servers without requiring a trusted, manually-issued certificate. On first use it generates a self-signed RSA certificate and key pair using node-forge, caches the result on disk (inside the project’s Vite cache directory by default, or a custom certDir), and reuses it on subsequent runs until it expires.

The certificate covers localhost, 127.0.0.1, [::1], and fe80::1 by default, plus any additional domains passed via the domains option, so it works for typical local development flows including access from other devices on a LAN. Expiration is tracked via Node’s X509Certificate API (falling back to manual parsing of the nonstandard validTo string on older Node versions) and the certificate is regenerated automatically once it’s stale, controlled by the ttlDays option (30 days by default).

Because the certificate is self-signed and untrusted by browsers, visiting the dev server still shows a security warning that must be bypassed manually — this plugin trades that one-time friction for the ability to test HTTPS-only behavior (service workers, secure cookies, WebRTC, etc.) locally without configuring a real CA-issued cert. It plugs directly into Vite’s configResolved hook, setting server.https and preview.https only when they haven’t been explicitly disabled, so it composes cleanly with existing Vite HTTPS configuration.

What You Get

  • Zero-config HTTPS - drop the plugin into vite.config.js and both the dev and preview servers immediately serve over HTTPS.
  • Automatic certificate caching - the generated cert/key pair is written to disk (Vite’s cache dir by default) so it isn’t regenerated on every server start.
  • Expiration-aware regeneration - certificates are checked against their validity window on each run and silently regenerated once expired.
  • Custom domains and TTL - configurable domains, name, ttlDays, and certDir options for matching real-world hostnames or custom cache locations.
  • Non-destructive integration - only sets server.https/preview.https when the user hasn’t already explicitly disabled HTTPS, so it won’t fight existing config.

Common Use Cases

  • Testing HTTPS-only browser APIs locally - a developer needs to test service workers, secure cookies, or WebRTC features that require a secure context, without provisioning a real certificate.
  • Cross-device LAN testing - a mobile developer wants to hit the dev server from a phone on the same network over HTTPS, adding the phone’s hostname via the domains option.
  • Quick HTTPS smoke tests before deploying TLS-terminated infra - a team wants to sanity-check HTTPS-dependent redirects or headers before their production TLS termination is configured.
  • Onboarding-friendly local setup - a project wants new contributors to get a working HTTPS dev environment with no manual certificate steps, just pnpm dev.

Under The Hood

Architecture The plugin is a small, single-purpose Vite plugin defined in src/index.ts: it hooks into Vite’s configResolved lifecycle to lazily generate or read a cached certificate and then assigns it to config.server.https and config.preview.https via Object.assign, preserving any existing HTTPS options the user set. Certificate generation is isolated in src/certificate.ts (a self-contained fork of the selfsigned library’s logic, using node-forge directly to keep the bundle smaller) and expiration checking is isolated in src/certificate-expiration.ts, which wraps Node’s X509Certificate with a fallback parser for the nonstandard validTo date format on older Node versions. The separation between plugin wiring, certificate creation, and expiration logic keeps each concern in its own file with a narrow, testable surface.

Tech Stack Written in TypeScript and built with unbuild, targeting Node 18/20/22+, with vite (6.x-8.x) as a peer dependency and node-forge as the sole runtime dependency for certificate generation. The package ships dual ESM/CJS builds (dist/index.mjs and dist/index.cjs) plus type declarations. Development tooling is a standard modern npm-ecosystem setup: pnpm workspaces, vitest for tests, prettier for formatting, and tsx for running release scripts.

Code Quality Test coverage is focused and pragmatic: test/test.spec.ts covers certificate creation, expiration detection under both the modern validToDate API and the legacy validTo string-parsing fallback (mocking X509Certificate getters with vitest’s vi.spyOn), and the nonstandard date parser directly. Error handling is minimal but deliberate — certificate cache reads fall back silently to regeneration on any read failure, and cache writes are fire-and-forget so a failed write never breaks the dev server. Naming and typing are consistent and the codebase is small enough that its scope stays easy to reason about.

What Makes It Unique Rather than depending on the full selfsigned npm package, the maintainers inlined and trimmed just the certificate-generation logic they needed directly from it (with attribution preserved in comments), avoiding an extra dependency and keeping the bundle lean. Combining that with automatic on-disk caching and expiration-aware regeneration means the certificate lifecycle is handled transparently — most consumers never think about it after adding the plugin once.

Used by 8 apps in this directory

TypeScript
94%
MIT

Actual

Invoicing Finance

28,593

Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.

View details
93
Repo Health
85
Technical
77
Dependency
Built with
TypeScript94%
Updated today
Java
73%
Other

ByteChef

Automation · AI Agents

1,000

Unified open-source platform for AI agent orchestration and workflow automation with 180+ connectors, MCP support, and durable execution.

View details
85
Repo Health
82
Technical
70
Dependency
Built with
Java73%
TypeScript26%
Updated yesterday
TypeScript
96%
Other

Cal.diy

Scheduling

48,218

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
95
Repo Health
86
Technical
65
Dependency
Built with
TypeScript96%
Updated yesterday
Vue
54%
GPL 3.0

Financial Freedom

Invoicing Finance

2,923

Own your financial data with a self-hosted, privacy-first budgeting app that replaces Mint and YNAB.

View details
48
Repo Health
67
Technical
74
Dependency
Built with
Vue54%
PHP44%
Updated 4 months ago
Rust
52%
Other

hoodik

File Storage · Security

1,468

Self-hosted, end-to-end encrypted cloud storage with browser-based encryption and S3-compatible storage support

View details
75
Repo Health
71
Technical
64
Dependency
Built with
Rust52%
TypeScript33%
Vue14%
Updated 1 weeks ago
TypeScript
100%
Apache 2.0

ILLA Builder

Developer Tools · Low Code Platforms · No Code Platforms

12,312

Open-source low-code platform for building internal tools with drag-and-drop UI, reactive data bindings, and real-time collaboration.

View details
57
Repo Health
71
Technical
63
Dependency
Built with
TypeScript100%
Updated 3 months ago
TypeScript
99%
MIT

Sanity

CMS

6,312

Open-source headless CMS with a fully customizable React Studio, real-time collaborative editing, structured content modeling, and GROQ query language

View details
92
Repo Health
90
Technical
66
Dependency
Built with
TypeScript99%
Updated yesterday
Go
64%
GPL 3.0

Stormkit

Devops · Hosting Control Panel

256

Self-hostable platform for deploying and hosting modern web apps with automated CI/CD, custom domains, and a built-in serverless runtime — a true open-source alternative to Vercel and Netlify.

View details
78
Repo Health
79
Technical
67
Dependency
Built with
Go64%
TypeScript33%
Updated 3 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search