Hi, I'm looking for more info regarding the follo...
# ask-questions
Hi, I'm looking for more info regarding the following feature: Load at build-time (static generation) reference: https://docs.growthbook.io/app/features#load-at-build-time-static-generation
What framework are you using for static generation?
react, nodejs
not using any framework
I thought it means a compile-time solution (react build)
Ok. The basic process is to fetch your feature definition JSON from the GrowthBook API and embed that in your JavaScript bundle. Then use the react SDK and pass in that JSON object.
The only different to the other approaches is that there's no network request to fetch the features and everything is bundled together with your app.
do you have a feature to support removing code at build time? We are providing on premise solution and we would like not to deliver experimental code to clients.
We do not. It might be possible to do with environment variables. You could run a nodejs script that pulls features from the GrowthBook API, evaluates all of the features, and writes the values to a .env file. Then you can wrap code in
if(process.env.FEATURE_KEY) {
and your build process should be able to identify dead code and remove it.
👍 2