You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Workers] update local dev tunnel guides and add changelog (#30822)
* docs(workers): add local dev tunnel guides and changelog
* preview future chanelog
* tighten changelog wording
* link to access control and update demo gif
* Clarify tunnel starting instructions in changelog
Updated instructions for starting a tunnel and added details on named tunnels.
---------
Co-authored-by: Matt ‘TK’ Taylor <matttaylor@cloudflare.com>
title: Share local dev servers through Cloudflare Tunnel in Wrangler and Vite
3
+
description: You can now share local dev servers through Cloudflare Tunnel from Wrangler and the Cloudflare Vite plugin, with support for quick tunnels and named tunnels.
4
+
products:
5
+
- workers
6
+
date: 2026-05-18
7
+
publish_future_dated_entry: true
8
+
---
9
+
10
+
You can now share local dev sessions through [Cloudflare Tunnel](/tunnel/) and get a public URL when using either [Wrangler](/workers/wrangler/) or the [Cloudflare Vite plugin](/workers/vite-plugin/). This is useful when you need to share a preview, test a webhook, or access your app from another device.
11
+
12
+

13
+
14
+
This lets you either:
15
+
16
+
- start a temporary [Quick tunnel](/tunnel/setup/#quick-tunnels-development) with a random `*.trycloudflare.com` hostname, or
17
+
- use an existing [named tunnel](/tunnel/setup/#create-a-tunnel) for a stable hostname and to restrict access with [Cloudflare Access](/cloudflare-one/access-controls/).
18
+
19
+
To start a tunnel, press `t` in Wrangler or `t + Enter` in Vite while your dev server is running. For details on setting up a named tunnel, refer to [Share a local dev server](/workers/development-testing/local-dev-tunnels/).
You can expose your local dev server over a [Cloudflare Quick Tunnel](/tunnel/setup/#quick-tunnels-development) when you need to share a preview, test a webhook, or access your app from another device. This provides a random `*.trycloudflare.com` hostname for the current dev session.
12
+
You can expose your local dev server over a [Cloudflare Tunnel](/tunnel/) when you need to share a preview, test a webhook, or access your app from another device.
13
13
14
14
This page covers tunnel support in [Wrangler](/workers/wrangler/commands/general/#dev) and the [Cloudflare Vite plugin](/workers/vite-plugin/).
15
15
16
16
## Start a tunnel
17
17
18
+
You can start a tunnel with Wrangler or the Cloudflare Vite plugin for the current session. This gives you either a random `*.trycloudflare.com` hostname via a [Quick tunnel](/tunnel/setup/#quick-tunnels-development), or a stable hostname via a [named tunnel](/tunnel/setup/#create-a-tunnel).
19
+
18
20
**Wrangler**
19
21
20
-
Run `wrangler dev --tunnel`:
22
+
Run `wrangler dev`, then press `[t]` to start or close the tunnel. Wrangler will print the public tunnel URL or URLs for the current session.
Enable `tunnel` conditionally in the plugin config:
34
+
Run `vite dev`, then press `t + Enter` to start or close the tunnel. Add `tunnel` to the plugin config if you want to configure a named tunnel or have the tunnel open automatically when Vite starts.
35
+
36
+
To use a named tunnel with stable hostnames:
29
37
30
38
<TypeScriptExamplefilename="vite.config.ts">
31
39
```ts
@@ -35,26 +43,44 @@ import { cloudflare } from "@cloudflare/vite-plugin";
35
43
exportdefaultdefineConfig({
36
44
plugins: [
37
45
cloudflare({
38
-
tunnel: process.env.ENABLE_DEV_TUNNEL==="true",
46
+
tunnel: { name: "my-tunnel" },
39
47
}),
40
48
],
41
49
});
42
50
```
43
51
</TypeScriptExample>
44
52
45
-
Then enable the tunnel only for the sessions where you want a public URL:
53
+
If you want the tunnel to open automatically when Vite starts, set `tunnel.autoStart` to `true`.
46
54
47
-
```sh
48
-
ENABLE_DEV_TUNNEL=true vite dev # or "vite preview"
49
-
```
55
+
When using `vite preview`, Vite's preview host validation still applies:
56
+
57
+
- For Quick tunnel, add `.trycloudflare.com` to `preview.allowedHosts`.
58
+
- For named tunnel, add the resolved hostnames or a matching domain suffix such as `.my-domain.com` to `preview.allowedHosts`.
50
59
51
-
Once the tunnel opens:
60
+
For example:
52
61
53
-
- The public tunnel URL is printed in the terminal for the current dev session.
54
-
- The session expires after 1 hour by default.
55
-
- A reminder is logged every 10 minutes while the tunnel is open.
56
-
- You can extend the tunnel by 1 hour at a time, either by pressing `t` for Wrangler or `t + Enter` for Vite.
57
-
- The tunnel can be extended up to 3 hours of remaining time.
Open a publicly reachable Cloudflare Quick Tunnel for sharing a preview, testing webhooks, or accessing the app from another device.
81
+
Expose your local dev server over a [Cloudflare Tunnel](/tunnel/).
82
+
83
+
Provide an object to configure a named tunnel or control whether the tunnel starts automatically. Press `t + Enter` to start or close the tunnel. Set `tunnel.autoStart` to `true` if you want the tunnel to open when Vite starts.
- Open a publicly reachable Cloudflare Quick Tunnel for sharing a preview, testing webhooks, or accessing the app from another device.
126
-
- For more information, refer to [Share a local dev server](/workers/development-testing/local-dev-tunnels/).
125
+
- Expose your local dev server over a Cloudflare Tunnel. For more information, refer to [Share a local dev server](/workers/development-testing/local-dev-tunnels/).
- Exposes a `/__scheduled` fetch route which will trigger a scheduled event (Cron Trigger) for testing during development. To simulate different cron patterns, a `cron` query parameter can be passed in: `/__scheduled?cron=*+*+*+*+*` or `/cdn-cgi/handler/scheduled?cron=*+*+*+*+*`.
0 commit comments