Skip to content

Commit

Permalink
Update SSR instructions in README.md (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
mltsy authored Mar 7, 2024
1 parent 6bb5c89 commit d1a3ff2
Showing 1 changed file with 6 additions and 4 deletions.
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

0 comments on commit d1a3ff2

Please sign in to comment.