{"id":27516,"library":"vite-plugin-cloudflare-tunnel","title":"Vite Plugin Cloudflare Tunnel","description":"A Vite plugin (v1.0.12) that automatically creates and manages Cloudflare tunnels for local development, exposing local dev servers to the internet with HTTPS without port forwarding. Offers two modes: Quick Tunnel (zero-config, generates random trycloudflare.com URL) and Named Tunnel (custom domains via Cloudflare API). Requires Vite 4/5/7 and Node >=16. Releases via npm; TypeScript types included. Simpler than manual cloudflared usage or ngrok alternatives.","status":"active","version":"1.0.12","language":"javascript","source_language":"en","source_url":"https://github.com/eastlondoner/vite-plugin-cloudflare-tunnel","tags":["javascript","vite","vite-plugin","cloudflare","tunnel","development","local-development","typescript"],"install":[{"cmd":"npm install vite-plugin-cloudflare-tunnel","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-cloudflare-tunnel","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-cloudflare-tunnel","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin integrates with Vite's dev server lifecycle.","package":"vite","optional":false}],"imports":[{"note":"This is the default export; named import will fail. TypeScript definitions are included.","wrong":"import { cloudflareTunnel } from 'vite-plugin-cloudflare-tunnel'","symbol":"cloudflareTunnel","correct":"import cloudflareTunnel from 'vite-plugin-cloudflare-tunnel'"},{"note":"CommonJS require must access .default. For ESM projects, use default import.","wrong":"const cloudflareTunnel = require('vite-plugin-cloudflare-tunnel')","symbol":"default import (CommonJS require)","correct":"const cloudflareTunnel = require('vite-plugin-cloudflare-tunnel').default"},{"note":"Type is not exported as a value; only use for type annotations.","wrong":"","symbol":"CloudflareTunnelOptions (TypeScript type)","correct":"import type { CloudflareTunnelOptions } from 'vite-plugin-cloudflare-tunnel'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport cloudflareTunnel from 'vite-plugin-cloudflare-tunnel';\n\nexport default defineConfig({\n  plugins: [\n    cloudflareTunnel() // Quick Tunnel mode – no config needed\n  ]\n});","lang":"typescript","description":"Zero-configuration setup: imports the plugin and adds it to Vite's plugin array. Running npm run dev will print a public https://*.trycloudflare.com URL."},"warnings":[{"fix":"Install cloudflared manually via package manager or ensure internet access for automatic download.","message":"The plugin requires cloudflared binary to be installed. It attempts to download it automatically, but may fail in restricted environments.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set CLOUDFLARE_API_KEY environment variable. If passing apiToken, use string value, not object.","message":"Named Tunnel mode requires CLOUDFLARE_API_KEY environment variable or apiToken option with correct permissions (Cloudflare Tunnel:Edit, SSL/Certs:Edit, DNS:Edit). Missing or wrong permissions cause cryptic errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use Named Tunnel mode if you need a persistent URL or if corporate firewall blocks trycloudflare.com.","message":"Quick Tunnel mode (no options) does NOT require any Cloudflare account or API token. It uses trycloudflare.com subdomain which is ephemeral and may be blocked on corporate networks requiring HTTPS inspection.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use Vite 4 or 5; Vite 6 may be incompatible unless the plugin explicitly supports it.","message":"The package README references vite ^4.0.0 || ^5.0.0 || ^7.0.0 as peer dep, but Vite 7 might not be released yet. Ensure compatibility with your Vite version.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Wait a few seconds after dev server starts before accessing tunnel URL.","message":"The plugin starts the tunnel asynchronously after Vite dev server boots. Hot reload works but initial page load on the tunnel URL may have a brief delay while tunnel is established.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Manually install cloudflared (e.g., 'npm install -g cloudflared' or download from Cloudflare), or ensure network access.","cause":"Automatic cloudflared download failed or was blocked.","error":"Error: Cannot find module 'cloudflared'"},{"fix":"Change to 'import cloudflareTunnel from 'vite-plugin-cloudflare-tunnel'' (no curly braces).","cause":"Using named import instead of default import.","error":"TypeError: cloudflareTunnel is not a function"},{"fix":"Set CLOUDFLARE_API_KEY to a valid Cloudflare API token with proper permissions.","cause":"CLOUDFLARE_API_KEY environment variable is not set or incorrect for Named Tunnel mode.","error":"Invalid token: The token provided is not valid"},{"fix":"Either call cloudflareTunnel() without arguments for quick mode, or provide hostname and tunnelName for named mode.","cause":"Passed an empty object or invalid options to cloudflareTunnel({}) where hostname is missing for named tunnel mode.","error":"Error: You need to specify a hostname or leave empty for quick tunnel"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}