Open KjetilIN opened 1 year ago
Probably the best option:
Tried to fix but found no clear solution. The key problem is that Flagsmith does not have great documentation for Next 13 integration. Tried a lot of diffrent things. For instance;
flagsmith.init(
{environmentID: 'XXXX'}
)
Tried also some of this;
import { FlagsmithProvider } from 'flagsmith/react';
import flagsmith, { createFlagsmithInstance } from 'flagsmith/isomorphic';
function MyApp({ Component, pageProps, flagsmithState }) {
return (
<FlagsmithProvider flagsmith={flagsmith} serverState={flagsmithState}>
<Component {...pageProps} />
</FlagsmithProvider>
);
}
MyApp.getInitialProps = async () => {
// This could be getStaticProps too depending on your build flow.
// Using createFlagsmithInstance rather than flagsmith here is only necessary if your servers allow for concurrent requests to getInitialProps.
const flagsmithSSR = createFlagsmithInstance();
await flagsmithSSR.init({
// fetches flags on the server
environmentID: '<YOUR_ENVIRONMENT_ID>',
identity: 'my_user_id', // optionaly specify the identity of the user to get their specific flags
});
return { flagsmithState: flagsmithSSR.getState() };
};
export default MyApp;
Read more here; https://docs.flagsmith.com/clients/next-ssr
Maybe a list of booleans that we set based on what .ENV is set
Look into a feature toggle system! Why? We only want to show some of the features on our website.
Some options to consider;