Registry / devops / vite-plugin-ngrok

vite-plugin-ngrok

JSON →
library2.0.1jsnpmunverified

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-ngrok
INSTALL
IMPORT
SIG · VITE-PLUGIN-NGROK
V
vite-plugin-ngrok
devopsjavascriptv2.0.1
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.

ngrok
import { ngrok } from 'vite-plugin-ngrok'
import ngrok from 'vite-plugin-ngrok'
The plugin exports a named export 'ngrok'. Default import is not available.
default
import { ngrok } from 'vite-plugin-ngrok'
const ngrok = require('vite-plugin-ngrok')
Package is ESM-only. CommonJS require will not work.
type
import type { ngrok } from 'vite-plugin-ngrok'
TypeScript type import for type-checking only. The 'ngrok' export is a function.

Basic usage: configure ngrok plugin with auth token from environment variable. Requires @ngrok/ngrok and Vite as dependencies.

// vite.config.ts import { defineConfig } from 'vite' import { ngrok } from 'vite-plugin-ngrok' export default defineConfig({ plugins: [ ngrok(process.env.NGROK_AUTH_TOKEN ?? ''), ], })
Debug
Known issues
breakingIn v2.0.0, the plugin switched from @ngrok/ngrok SDK v1 to v2, which has breaking changes in configuration options (see ngrok SDK changelog).
fix
Update your ngrok config object to match @ngrok/ngrok v2 API. If using string argument, API remains same.
affects: >=2.0.0
breakingIn v2.0.0, the peer dependency on Vite changed to '^5.4.12 || ^6.0.0 || ^7.0.0'. Vite versions below 5.4.12 are no longer supported.
fix
Upgrade Vite to ^5.4.12, ^6.0.0, or ^7.0.0.
affects: >=2.0.0
deprecatedPassing a plain string with the auth token directly in code is discouraged for security reasons (token stored in git).
fix
Use environment variables: load via loadEnv() or process.env, or set authtoken_from_env: true and set NGROK_AUTHTOKEN env var.
affects: >=1.0.0
gotchaThe plugin only creates tunnels during local dev (vite dev). It does not run during build (vite build).
fix
This is by design. Do not expect tunnels in production builds.
affects: >=1.0.0
gotchaWhen passing an object to ngrok(), the default port from Vite is automatically set, but any explicitly provided port will override that default.
fix
If you need a specific port, set it in the ngrok config object. Otherwise, Vite's dev port is used automatically.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module '@ngrok/ngrok'
@ngrok/ngrok is not installed or is a missing dependency.
fix
Run 'npm install @ngrok/ngrok' (or your package manager equivalent) and ensure it is in your dependencies.
TypeError: ngrok is not a function
Default import used instead of named import.
fix
Use import { ngrok } from 'vite-plugin-ngrok' instead of import ngrok from 'vite-plugin-ngrok'.
Error: The 'authtoken' property must be a string
An object was passed to ngrok() that does not have a valid authtoken or authtoken_from_env set.
fix
Ensure the object contains either authtoken: 'YOUR_TOKEN' or authtoken_from_env: true (and NGROK_AUTHTOKEN env var is set).
error:0308010C:digital envelope routines::unsupported
This error is not from vite-plugin-ngrok itself, but occurs when using ngrok tunnels with older Node.js versions (e.g., Node 17+ with OpenSSL 3).
fix
Set environment variable NODE_OPTIONS=--openssl-legacy-provider or upgrade Node.js.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
@ngrok/ngrokrequiredCore tunnel creation; this plugin wraps the official ngrok JavaScript SDK.
viterequiredPeer dependency on Vite (^5.4.12 || ^6.0.0 || ^7.0.0); required for plugin to work.
Agent activity
20 hits · last 30 days
node
16
OpenAI (training)
1
Resources
vite-plugin-ngrok — npm install vite-plugin-ngrok · libregistry