IT-Start-Gjovik / startgjovik_website

Website for Start Gjøvik 2023-2024, a student organization for innovation and entrepreneurship
https://www.startgjovik.no
GNU General Public License v2.0
9 stars 7 forks source link

Feature toggle #45

Open KjetilIN opened 1 year ago

KjetilIN commented 1 year ago

Look into a feature toggle system! Why? We only want to show some of the features on our website.

Some options to consider;

KjetilIN commented 1 year ago

Probably the best option: image

KjetilIN commented 1 year ago

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

KjetilIN commented 1 year ago

Maybe a list of booleans that we set based on what .ENV is set