Vite plugin (v2.0.1) for automatically creating ngrok tunnels during local development, enabling instant sharing of local Vite dev servers over the internet. Uses the official @ngrok/ngrok JavaScript SDK. Supports configuration via string (auth token) or full ngrok Config object. Dynamically updates URLs on server restart or tunnel reopen. Peer dependency on Vite ^5.4.12, ^6.0.0, or ^7.0.0. Ships TypeScript types. Differentiator: minimal setup (single line plugin) vs manual ngrok CLI or separate tools.
npm install vite-plugin-ngrokVerified import paths — ran on the pinned version, not inferred.
Basic usage: configure ngrok plugin with auth token from environment variable. Requires @ngrok/ngrok and Vite as dependencies.
Update your ngrok config object to match @ngrok/ngrok v2 API. If using string argument, API remains same.
Upgrade Vite to ^5.4.12, ^6.0.0, or ^7.0.0.
Use environment variables: load via loadEnv() or process.env, or set authtoken_from_env: true and set NGROK_AUTHTOKEN env var.
This is by design. Do not expect tunnels in production builds.
If you need a specific port, set it in the ngrok config object. Otherwise, Vite's dev port is used automatically.
Run 'npm install @ngrok/ngrok' (or your package manager equivalent) and ensure it is in your dependencies.
Use import { ngrok } from 'vite-plugin-ngrok' instead of import ngrok from 'vite-plugin-ngrok'.Ensure the object contains either authtoken: 'YOUR_TOKEN' or authtoken_from_env: true (and NGROK_AUTHTOKEN env var is set).
Set environment variable NODE_OPTIONS=--openssl-legacy-provider or upgrade Node.js.