-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathclient-side-rendering.tsx
39 lines (37 loc) · 1.4 KB
/
client-side-rendering.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
import * as React from "react";
import { Layout } from "../../components/Layout";
import { Result } from "../../components/Result";
import { useFlags } from "@happykit/flags/client";
import { AppFlags } from "../../types/AppFlags";
export default function Page() {
const flagBag = useFlags<AppFlags>();
return (
<Layout
title="Client-Side Rendering"
source={`https://github.com/happykit/flags/blob/${process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF}/example/pages/demo/client-side-rendering.tsx`}
flagBag={flagBag}
>
<article className="py-4 prose max-w-prose">
<p>
This demo shows how to use <code>@happykit/flags</code> for regular
pages.
</p>
<p>
In this configuration, the feature flags will be loaded when the
client renders the page. They will not be loaded at build time. Check
the Static Site Generation examples if you need that, or the
Server-Side Rendering examples.
</p>
<p>
When the page mounts, <code>@happykit/flags</code> will fetch the
latest flags from the server and render the page accordingly.
</p>
<p>
The <code>settled</code> value will then flip to true after the
evaluation on the client finishes.
</p>
<Result key="static-site-generation-hybrid" value={flagBag} />
</article>
</Layout>
);
}