Skip to content

Commit 07b1509

Browse files
committed
feat: add NotFound component and route for handling 404 errors
1 parent c927244 commit 07b1509

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

src/app/router.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Routes, Route } from "react-router";
22
import LoadingPage from "@/components/LoadingPage";
33

44
import { Suspense, lazy } from "react";
5+
import NotFound from "@/components/NotFound";
56

67
const SplashRoute = lazy(() =>
78
import("../features/splash/Splash").then((module) => ({
@@ -132,6 +133,7 @@ export default function AppRouter() {
132133
</Suspense>
133134
}
134135
/>
136+
<Route path="*" element={<NotFound />} />
135137
</Routes>
136138
);
137139
}

src/components/NotFound.tsx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { Link } from "react-router";
2+
import { useMemo } from "react";
3+
import { HTHeader } from "./HTHeader";
4+
import { HTFooter } from "./HTFooter";
5+
6+
const messages = [
7+
"404: This path is off the grid. It either got wiped or never existed.",
8+
"Dead link detected. The resource you’re probing isn’t here.",
9+
"Nothing to see here—this route’s a ghost in the machine.",
10+
"Page not found. Either it’s been moved, or it was just a rumor.",
11+
"You’ve reached a null sector. No data lives at this address.",
12+
"Invalid opcode. This page cannot be executed.",
13+
"Access denied: target not in scope.",
14+
"Glitch in the system. That page never compiled.",
15+
];
16+
17+
export default function NotFound() {
18+
const message = useMemo(
19+
() => messages[Math.floor(Math.random() * messages.length)],
20+
[]
21+
);
22+
23+
return (
24+
<div className="min-h-dvh flex flex-col">
25+
<HTHeader />
26+
27+
<main id="main" className="flex-1 flex items-center justify-center px-6">
28+
<div className="text-center">
29+
<h1 className="text-4xl md:text-6xl font-extrabold tracking-tight text-gray-100">
30+
404 — Page not found
31+
</h1>
32+
<p className="mt-4 text-gray-400">{message}</p>
33+
34+
<div className="mt-8 flex flex-wrap items-center justify-center gap-3">
35+
<Link
36+
to="/conferences"
37+
className="rounded-md border border-gray-700 px-4 py-2
38+
text-gray-200 hover:bg-gray-800
39+
focus:outline-none focus:ring-2 focus:ring-indigo-400
40+
transition-colors"
41+
>
42+
Browse Conferences
43+
</Link>
44+
<Link
45+
to="/"
46+
className="rounded-md border border-gray-700 px-4 py-2
47+
text-gray-200 hover:bg-gray-800
48+
focus:outline-none focus:ring-2 focus:ring-indigo-400
49+
transition-colors"
50+
>
51+
Home
52+
</Link>
53+
</div>
54+
</div>
55+
</main>
56+
57+
<HTFooter />
58+
</div>
59+
);
60+
}

0 commit comments

Comments
 (0)