-
Notifications
You must be signed in to change notification settings - Fork 8
/
[id].tsx
48 lines (40 loc) · 1.01 KB
/
[id].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
import Head from 'next/head'
import { Links } from '../../src/components/Links'
import { ViewStateForm } from '../../src/components/ViewStateForm'
import styles from '../../styles/Home.module.css'
import type { GetServerSideProps, NextPage } from 'next'
type Props = {
id: string
}
const SSRPage: NextPage<Props> = ({ id }) => {
return (
<div className={styles.container}>
<Head>
<title>SSR - Example of RecoilHistorySyncJSONNext</title>
</Head>
<main className={styles.main}>
<h1 className={styles.title}>SSR Page {id}</h1>
<div>
<h2>ViewState</h2>
<ViewStateForm />
</div>
<div>
<h2>Links</h2>
<Links />
</div>
</main>
</div>
)
}
export default SSRPage
export const getServerSideProps: GetServerSideProps<
Props,
{ id: string }
> = async ({ params }) => {
if (params?.id === undefined) throw new Error('`params.id` is undefined.')
return {
props: {
id: params?.id,
},
}
}