Co-authored by
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 JTBDOS project to use Hypertune for feature flags!
1. Create a new Hypertune project
Go to Hypertune and create a new project using the JTBDOS 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:apps/app/.env
.env file to the feature-flags package with the following contents:
packages/feature-flags/.env
3. Update the keys.ts file in the feature-flags package
Use the NEXT_PUBLIC_HYPERTUNE_TOKEN environment variable in the call to createEnv:
packages/feature-flags/keys.ts
4. Swap out the required dependencies
First, delete thecreate-flag.ts file.
Then, uninstall the existing dependencies from the feature-flags package:
Terminal
Terminal
5. Set up Hypertune code generation
Addanalyze and build scripts to the package.json file for the feature-flags package, which both execute the hypertune command:
packages/feature-flags/package.json
Terminal
6. Set up Hypertune client instance
Add agetHypertune.ts file in the feature-flags package which defines a getHypertune function that returns an initialized instance of the Hypertune SDK on the server:
packages/feature-flags/lib/getHypertune.ts
7. Update index.ts
Hypertune automatically generates feature flag functions that use the @vercel/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:
packages/feature-flags/index.ts
Flag suffix to all these generated feature flag functions, so you will need to update flag usages with this, e.g. showBetaFeature => showBetaFeatureFlag.