Skip to content

Commit 1297bb5

Browse files
committed
add: default not found component for tanstack under apps/web
1 parent 76f36c7 commit 1297bb5

2 files changed

Lines changed: 60 additions & 22 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Link } from "@tanstack/react-router";
2+
import { Button } from "@/components/ui/button";
3+
4+
export function NotFound() {
5+
return (
6+
<div className="flex min-h-svh flex-col items-center justify-center gap-6 bg-background p-6 text-center">
7+
<div className="flex flex-col items-center gap-2">
8+
<h1 className="text-7xl font-bold tracking-tighter text-foreground">
9+
404
10+
</h1>
11+
<h2 className="text-xl font-semibold text-foreground">
12+
Page not found
13+
</h2>
14+
<p className="max-w-md text-sm text-muted-foreground">
15+
The page you're looking for doesn't exist or has been moved.
16+
</p>
17+
</div>
18+
<div className="flex gap-3">
19+
<Button variant="outline" onClick={() => window.history.back()}>
20+
Go back
21+
</Button>
22+
<Button asChild>
23+
<Link to="/">Return home</Link>
24+
</Button>
25+
</div>
26+
</div>
27+
);
28+
}

apps/web/src/routes/__root.tsx

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,72 @@
1-
import { HeadContent, Scripts, createRootRoute } from '@tanstack/react-router'
2-
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
3-
import { TanStackDevtools } from '@tanstack/react-devtools'
1+
import {
2+
HeadContent,
3+
Outlet,
4+
Scripts,
5+
createRootRoute,
6+
} from "@tanstack/react-router";
7+
import { TanStackRouterDevtoolsPanel } from "@tanstack/react-router-devtools";
8+
import { TanStackDevtools } from "@tanstack/react-devtools";
49

10+
import { ConvexClerkProvider } from "../lib/convex-clerk";
11+
import { ThemeProvider } from "../components/dashboard/ThemeProvider";
12+
import { Toaster } from "@/components/ui/sonner";
13+
import { MonitoringErrorBoundary } from "@stackdock/monitoring";
14+
import { initWebMonitoring } from "../lib/monitoring";
15+
import { NotFound } from "../components/NotFound";
516

6-
import { ConvexClerkProvider } from '../lib/convex-clerk'
7-
import { ThemeProvider } from '../components/dashboard/ThemeProvider'
8-
import { Toaster } from '@/components/ui/sonner'
9-
import { MonitoringErrorBoundary } from '@stackdock/monitoring'
10-
import { initWebMonitoring } from '../lib/monitoring'
11-
12-
import appCss from '../styles.css?url'
17+
import appCss from "../styles.css?url";
1318

1419
// Initialize monitoring
15-
initWebMonitoring()
20+
initWebMonitoring();
1621

1722
export const Route = createRootRoute({
1823
head: () => ({
1924
meta: [
2025
{
21-
charSet: 'utf-8',
26+
charSet: "utf-8",
2227
},
2328
{
24-
name: 'viewport',
25-
content: 'width=device-width, initial-scale=1',
29+
name: "viewport",
30+
content: "width=device-width, initial-scale=1",
2631
},
2732
{
28-
title: 'StackDock',
33+
title: "StackDock",
2934
},
3035
],
3136
links: [
3237
{
33-
rel: 'stylesheet',
38+
rel: "stylesheet",
3439
href: appCss,
3540
},
3641
],
3742
}),
38-
43+
component: RootComponent,
44+
notFoundComponent: NotFound,
3945
shellComponent: RootDocument,
40-
})
46+
});
47+
48+
function RootComponent() {
49+
return <Outlet />;
50+
}
4151

4252
function RootDocument({ children }: { children: React.ReactNode }) {
4353
const content = (
4454
<>
4555
{children}
4656
<TanStackDevtools
4757
config={{
48-
position: 'bottom-right',
58+
position: "bottom-right",
4959
}}
5060
plugins={[
5161
{
52-
name: 'Tanstack Router',
62+
name: "Tanstack Router",
5363
render: <TanStackRouterDevtoolsPanel />,
5464
},
5565
]}
5666
/>
5767
<Scripts />
5868
</>
59-
)
69+
);
6070

6171
return (
6272
<html lang="en" suppressHydrationWarning>
@@ -97,5 +107,5 @@ function RootDocument({ children }: { children: React.ReactNode }) {
97107
</ThemeProvider>
98108
</body>
99109
</html>
100-
)
110+
);
101111
}

0 commit comments

Comments
 (0)