Skip to content

Commit 67089e4

Browse files
fibibotbartlomiejucrowlKats
authored
expand tunnel tutorial section with model and lifecycle (#3121)
Co-authored-by: fibibot <fibibot@users.noreply.github.com> Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Leo Kettmeir <crowlkats@toaxl.com>
1 parent 6e32e0c commit 67089e4

1 file changed

Lines changed: 33 additions & 15 deletions

File tree

examples/tutorials/tunnel.md

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
last_modified: 2026-03-24
2+
last_modified: 2026-05-14
33
title: "Share your local server with Tunnel"
44
description: "Expose a public URL instantly with the --tunnel option"
55
url: /examples/tunnel_tutorial/
@@ -78,34 +78,52 @@ Deploy console.
7878

7979
## Tunnel to your local server
8080

81-
The tunnel feature is built into the Deno CLI. It unlocks some of the powerful
82-
features of Deno deploy, but for your local server!
81+
The `--tunnel` flag is built into the Deno CLI. It opens a secure HTTPS tunnel
82+
from a public Deno Deploy URL to the server running on your local machine, so
83+
requests arrive at your local process as if it were the deployed application.
84+
The public URL is tied to the Deploy project you created in the previous step;
85+
it stays the same every time you restart the tunnel, which makes it safe to
86+
paste into a webhook config or share with a teammate without having to hand out
87+
a new URL each session.
8388

84-
To start a tunnel to your local server, run the following command in your
85-
project directory:
89+
`--tunnel` is available on any subcommand that runs a long-running server, so
90+
you can pair it with `deno run`, `deno task`, or `deno serve`. In this tutorial
91+
we're tunneling the Svelte `dev` task:
8692

8793
```sh
8894
deno run --tunnel dev
8995
```
9096

91-
If redirected to the browser, authenticate with your Deno Deploy account.
97+
The first time you run this, your browser will open so you can authenticate with
98+
your Deno Deploy account; subsequent runs reuse the cached credentials. After a
99+
few moments you should see output similar to this:
92100

93-
This command will start your local server and create a secure tunnel to it.
94-
After a few moments, you should see output similar to this:
95-
96-
```sh
101+
```console
97102
➜ Local: http://localhost:5173/
98103
➜ Network: use --host to expose
99104
➜ press h + enter to show help
100105
You are connected to https://my-app-name.myusername.deno.net
101106
```
102107

103-
That public url (`https://my-app-name.myusername.deno.net` in this example) is
104-
now accessible from anywhere on the internet! You can share this URL with others
105-
to access your local Svelte app, (much like ngrok or other tunneling services).
108+
That public URL (`https://my-app-name.myusername.deno.net` in this example) is
109+
now accessible from anywhere on the internet: share it with a colleague, point a
110+
webhook at it, or open it from your phone on a different network to test mobile
111+
layouts. Changes you make to your local code are reflected at the public URL in
112+
real time, just like local development.
113+
114+
To stop the tunnel, press `Ctrl+C` in the terminal. The public URL goes offline
115+
until you start the tunnel again. The deployed version of the project on Deno
116+
Deploy is not affected, `--tunnel` only redirects traffic for as long as the
117+
local command is running.
118+
119+
:::tip
120+
121+
If you want to expose a different local port (for example a backend on
122+
`localhost:8000` rather than the Vite dev server), run `deno serve --tunnel`
123+
against the file that listens on that port. The tunnel always forwards to the
124+
server the Deno command starts.
106125

107-
You can make changes to your local code as normal, and the changes will be
108-
reflected at the public URL in real-time.
126+
:::
109127

110128
## Configuring environment variables
111129

0 commit comments

Comments
 (0)