Skip to content

Commit 6479e88

Browse files
committed
UI: SSR example that works client side but not on server
This is due to NextJS bug: vercel/next.js#54977
1 parent c88047f commit 6479e88

8 files changed

Lines changed: 1221 additions & 17 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"use client"
2+
3+
import { KlevuInit, KlevuMerchandising } from "@klevu/ui-react"
4+
import "@klevu/ui/dist/klevu-ui/klevu-ui.css"
5+
6+
type Props = {
7+
categorySlug: string[]
8+
}
9+
10+
export default function CategoryPage(props: Props) {
11+
console.log(props)
12+
const category = props.categorySlug.join("/")
13+
14+
return (
15+
<KlevuInit
16+
url="https://eucs29v2.ksearchnet.com/cs/v2/search"
17+
apiKey="klevu-164651914788114877"
18+
>
19+
<KlevuMerchandising
20+
category={category}
21+
categoryTitle="Men's wear" // this needs to implemented in real solution
22+
/>
23+
</KlevuInit>
24+
)
25+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import CategoryPage from "./categoryPage"
2+
3+
export default async function Category(props: any) {
4+
return <CategoryPage categorySlug={props.params.slug} />
5+
}

examples/nextjs/app/globals.css

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,9 @@
88
--background-end-rgb: 255, 255, 255;
99
}
1010

11-
@media (prefers-color-scheme: dark) {
12-
:root {
13-
--foreground-rgb: 255, 255, 255;
14-
--background-start-rgb: 0, 0, 0;
15-
--background-end-rgb: 0, 0, 0;
16-
}
17-
}
18-
1911
body {
2012
color: rgb(var(--foreground-rgb));
13+
min-height: 100vh;
2114
background: linear-gradient(
2215
to bottom,
2316
transparent,

examples/nextjs/app/page.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Image from "next/image"
22
import { Fragment } from "react"
3+
import Link from "next/link"
34

45
export default function Home() {
56
return (
@@ -20,6 +21,10 @@ export default function Home() {
2021
/>
2122
</div>
2223
</form>
24+
<br />
25+
<Link href="/category/men">
26+
Category page with `@klevu/ui-react` here.
27+
</Link>
2328
</div>
2429
)
2530
}

0 commit comments

Comments
 (0)