import { useState } from "react"; import { Button } from "~/components/ui/button"; import { describePreviewError } from "./errorCodeMessages"; interface Props { url: string; /** Chromium net error code, e.g. -105. */ code: number; /** Stringified Chromium error, e.g. "ERR_NAME_NOT_RESOLVED". */ description: string; onReload: () => void; } /** Theme-aware tailwind port of Chromium's "This site can't be reached" page. */ export function PreviewUnreachable({ url, code, description, onReload }: Props) { const [showDetails, setShowDetails] = useState(false); const host = safeHost(url) ?? url; const friendly = describePreviewError(description); const errorLabel = description.length > 0 ? description : `ERR_${Math.abs(code) || "FAILED"}`; return (

This site can’t be reached

{host}: {friendly}.

{showDetails ? (

Try:

  • Checking your connection
  • Confirming the dev server is running
  • Checking the proxy and the firewall
) : null}
{errorLabel}
); } function ErrorIcon({ className }: { className?: string }) { return ( ); } function safeHost(url: string): string | null { try { return new URL(url).host; } catch { return null; } }