FeaturesGuidesDocumentationPricingGet Started

Next.js Dev Server Through a Tunnel

Configure allowedDevOrigins for Next.js 15.2+ when accessing your dev server through a LocalToLink tunnel.

Start the tunnel

# Terminal 1
npm run dev

# Terminal 2
npx localtolink --port 3000

Open the public URL (e.g. https://k7m2x9p4q1.localtolink.com) in a browser.

Next.js 15.2+ allowedDevOrigins

Next.js 15.2 added origin checks for the dev server. When accessing through a tunnel, add your tunnel domain to next.config.js (or next.config.ts):

/** @type {import('next').NextConfig} */
const nextConfig = {
  allowedDevOrigins: ["*.localtolink.com"],
};

export default nextConfig;

Restart npm run dev after changing the config.

Without this, you may see cross-origin errors or blocked dev server requests when loading the app through the tunnel URL.

Fallback: production build locally

If dev-server origin checks cause issues, test through a production build:

npm run build
npm run start
npx localtolink --port 3000

Production mode does not apply dev-only origin restrictions.

Browser interstitial

Browser access through the tunnel shows LocalToLink's one-time warning page. Click through to reach your app.

WebSocket / HMR

Next.js Fast Refresh uses WebSockets. LocalToLink supports WebSocket passthrough — HMR generally works through the tunnel once allowedDevOrigins is configured.

If HMR fails, use the production build fallback above.

Session notes

See also Vite HMR Through a Tunnel for Vite-specific configuration.

Try it now

Start a tunnel from your project directory — no account required.

$ npx localtolink

See the full CLI reference for flags and exit codes.

LocalToLink CLI 1.0.1 — verified 2026-09-05