-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
with-trpc.tsx
70 lines (63 loc) · 2.04 KB
/
with-trpc.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { unstable_noStore as noStore } from "next/cache";
import Link from "next/link";
import { CreatePost } from "~/app/_components/create-post";
import { api } from "~/trpc/server";
import styles from "./index.module.css";
export default async function Home() {
noStore();
const hello = await api.post.hello.query({ text: "from tRPC" });
return (
<main className={styles.main}>
<div className={styles.container}>
<h1 className={styles.title}>
Create <span className={styles.pinkSpan}>T3</span> App
</h1>
<div className={styles.cardRow}>
<Link
className={styles.card}
href="https://create.t3.gg/en/usage/first-steps"
target="_blank"
>
<h3 className={styles.cardTitle}>First Steps →</h3>
<div className={styles.cardText}>
Just the basics - Everything you need to know to set up your
database and authentication.
</div>
</Link>
<Link
className={styles.card}
href="https://create.t3.gg/en/introduction"
target="_blank"
>
<h3 className={styles.cardTitle}>Documentation →</h3>
<div className={styles.cardText}>
Learn more about Create T3 App, the libraries it uses, and how to
deploy it.
</div>
</Link>
</div>
<div className={styles.showcaseContainer}>
<p className={styles.showcaseText}>
{hello ? hello.greeting : "Loading tRPC query..."}
</p>
</div>
<CrudShowcase />
</div>
</main>
);
}
async function CrudShowcase() {
const latestPost = await api.post.getLatest.query();
return (
<div className={styles.showcaseContainer}>
{latestPost ? (
<p className={styles.showcaseText}>
Your most recent post: {latestPost.name}
</p>
) : (
<p className={styles.showcaseText}>You have no posts yet.</p>
)}
<CreatePost />
</div>
);
}