tnl.dev :: docs
vite.
Run a Vite app through tnl with its actual port and live reload.
add the vite plugin
In vite.config.ts, add tnl() alongside your existing plugins. tnl init can create the config or tell you where to add the plugin in an existing one:
import { defineConfig } from "vite";
import tnl from "@tnldotdev/tnl/vite";
export default defineConfig({ plugins: [tnl()] });Use Vite 6.0.9 or newer. For multiple services, select tnl({ service: "web" }). Put targets and access in project configuration, with explicit services.web.publicURL: {} for public HTTPS.
start vite with tnl
Run your existing Vite script, such as pnpm dev. The plugin prepares metadata and registers Vite's listener with local tnl. In another terminal, run tnl wait for public readiness or tnl status --scope=local for local facts. App startup does not apply remote group changes.
Vite still starts on localhost without a tnl account or when control is offline. It reports that the preview is unavailable and does not allow an unverified public hostname. Set TNL_PREVIEW=off to skip preview preparation, or TNL_PREVIEW=required to stop startup if the preview cannot be prepared. Sign in with tnl auth login and restart Vite when you want a public URL.
The plugin adds the assigned public hostname to Vite's allowed hosts and registers the port Vite actually opened, even if its preferred port was taken. Without a service publicURL block, it registers private HTTP instead. Vite middleware mode has no listener to publish.
use service urls and live reload
Vite makes project service URL metadata available in browser code:
import { tnl } from "@tnldotdev/tnl";
export const apiURL = tnl.services?.api?.url;Hot module reload, WebSockets, and streaming work through the public HTTPS URL. The plugin leaves production builds and preview alone. For two independent checkouts, see parallel worktrees.