Skip to content
Source
Sign inSign up
fuko/trytanstackdb.com
Open History to see the last commit

_tutorial._db.project-root.tsx

27 lines805 Bytes

1/**
2 NOTE: I don't know why, but without this file, the website I deploy on CF
3 throws a client-side error complaining about missing info about a server
4 function.
5 */
6import { createFileRoute } from "@tanstack/react-router";
7import { createServerFn } from "@tanstack/react-start";
8import { useEffect } from "react";
9import { getTutorialDataFromCookie } from "@/server/functions/getTutorialDataFromCookie";
10​
11const getServerTime = createServerFn().handler(() => ({
12 serverTime: Date.now(),
13}));
14​
15export const Route = createFileRoute("/_tutorial/_db/project-root")({
16 beforeLoad: async () => {},
17 component: RouteComponent,
18});
19​
20function RouteComponent() {
21 useEffect(() => {
22 getServerTime().then(console.log);
23 getTutorialDataFromCookie().then(console.log);
24 });
25​
26 return <div>hi</div>;