Switch to Hypertune
How to change the feature flag provider to Hypertune.
Hypertune is the most flexible platform for feature flags, A/B testing, analytics and app configuration. Built with full end-to-end type-safety, Git version control and local, synchronous, in-memory flag evaluation. Optimized for TypeScript, React and Next.js.
Here’s how to switch your next-forge project to use Hypertune for feature flags!
1. Create a new Hypertune project
Go to Hypertune and create a new project using the next-forge template. Then go to the Settings page of your project and copy the main token.
2. Update the environment variables
Update the environment variables across the project. For example:
Add a .env
file to the feature-flags
package with the following contents:
3. Update the keys.ts
file in the feature-flags
package
Use the NEXT_PUBLIC_HYPERTUNE_TOKEN
environment variable in the call to createEnv
:
4. Swap out the required dependencies
First, delete the create-flag.ts
file.
Then, uninstall the existing dependencies from the feature-flags
package:
Then, install the new dependencies:
5. Set up Hypertune code generation
Add analyze
and build
scripts to the package.json
file for the feature-flags
package, which both execute the hypertune
command:
Then run code generation with the following command:
This will generate the following files:
6. Set up Hypertune client instance
Add a getHypertune.ts
file in the feature-flags
package which defines a getHypertune
function that returns an initialized instance of the Hypertune SDK on the server:
7. Update index.ts
Hypertune automatically generates feature flag functions that use the flags
package. To export them the same way as before, update the index.ts
file to export everything from the generated/hypertune.vercel.ts
file:
Hypertune adds a Flag
suffix to all these generated feature flag functions, so you will need to update flag usages with this, e.g. showBetaFeature
=> showBetaFeatureFlag
.
8. Add more feature flags
To add more feature flags, create them in the Hypertune UI and then re-run code generation. They will be automatically added to your generated files.