Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SSR instructions in README.md #66

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ Both `getDefinitions()` and `getFrontendFlags()` can take arguments overriding U
import {
flagsClient,
evaluateFlags,
getFrontendFlags,
getDefinitions,
type IVariant,
} from "@unleash/nextjs";
import type { GetServerSideProps, NextPage } from "next";
Expand All @@ -241,12 +241,14 @@ export const getServerSideProps: GetServerSideProps<Data> = async (ctx) => {
// userId: "123" // etc
};

const { toggles } = await getFrontendFlags({ context }); // Use Proxy/Frontend API
const flags = flagsClient(toggles);
const definitions = await getDefinitions(); // Uses UNLEASH_SERVER_API_URL
const { toggles } = evaluateFlags(definitions, context);

const flags = flagsClient(toggles); // instantiates a static (non-syncing) unleash-proxy-client

return {
props: {
isEnabled: flags.isEnabled("nextjs-example"),
isEnabled: flags.isEnabled("nextjs-example")
},
};
};
Expand Down
Loading