-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroot.tsx
53 lines (47 loc) · 1.4 KB
/
root.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import type { LoaderFunction, MetaFunction } from "@remix-run/node";
import { Links, LiveReload, Meta, Outlet, Scripts, ScrollRestoration } from "@remix-run/react";
import { rootAuthLoader } from "@clerk/remix/ssr.server";
import { ClerkApp, ClerkCatchBoundary } from "@clerk/remix";
import styles from "~/styles/shared.css";
import Header from "~/components/Header";
export const meta: MetaFunction = () => {
return { title: "Lazy Clerk Remix" };
};
export function links() {
return [
{ rel: "stylesheet", href: "https://unpkg.com/[email protected]/dist/reset.min.css" },
{ rel: "stylesheet", href: styles },
];
}
export const loader: LoaderFunction = (args) => {
return rootAuthLoader(
args,
({ request }) => {
const { userId, sessionId, getToken } = request.auth;
console.log("Root loader auth:", { userId, sessionId, getToken });
return { message: `Hello from the root loader :)` };
},
{ loadUser: true }
);
};
function App() {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<Meta />
<Links />
</head>
<body>
<Header />
<Outlet />
<ScrollRestoration />
<Scripts />
<LiveReload />
</body>
</html>
);
}
export default ClerkApp(App);
export const CatchBoundary = ClerkCatchBoundary();