0.2.0 • Published 5 months ago
@flags-sdk/hypertune v0.2.0
Flags SDK — Hypertune Provider
The Hypertune adapter for the Flags SDK
Setup
The Hypertune provider is available in the @flags-sdk/hypertune module. You can install it with
pnpm i @flags-sdk/hypertuneProvider Instance
You must use the code generation powered by npx hypertune to create an adapter instance.
Use createHypertuneAdapter from @flags-sdk/hypertune as shown below:
/** Generated with `npx hypertune` */
import {
createSource,
vercelFlagDefinitions,
flagFallbacks,
type FlagValues,
type Context,
} from './generated/hypertune';
import { flag } from 'flags/next';
import { createHypertuneAdapter } from '@flags-sdk/hypertune';
import { identify } from './lib/identify';
/** Create the adapter with types generated by your app via `npx hypertune` */
const hypertuneAdapter = createHypertuneAdapter<FlagValues, Context>({
createSource,
flagDefinitions: vercelFlagDefinitions,
flagFallbacks,
identify,
});
/** Use the adapter to generate flag declarations for use in your app's framework */
export const showSummerBannerFlag = flag(
hypertuneAdapter.declarations.summerSale,
);
export const showFreeDeliveryBannerFlag = flag(
hypertuneAdapter.declarations.freeDelivery,
);
export const proceedToCheckoutColorFlag = flag(
hypertuneAdapter.declarations.proceedToCheckout,
);
/**
* NOTE: You can provide specific options for flag overrides
*
* However, using enums in hypertune will provide these automatically.
*/
export const delayFlag = flag({
...hypertuneAdapter.declarations.delay,
options: [
{ value: 0, label: 'No delay' },
{ value: 1_000, label: '1 second' },
{ value: 2_000, label: '2 seconds' },
{ value: 3_000, label: '3 seconds' },
],
});Required Environment Variables
# Required
NEXT_PUBLIC_HYPERTUNE_TOKEN="123="
# For use with precompute, encrypted flag values, overrides, and the Flags Explorer
FLAGS_SECRET="ReplaceThisWith32RandomBytesBase64UrlString"
# Optional: automatically configure with a VercelEdgeConfigInitDataProvider
EXPERIMENTATION_CONFIG="ecfg_abc"
EXPERIMENTATION_CONFIG_ITEM_KEY="hypertune_xyz"Documentation
Please check out the Hypertune Adapter reference for more information.
0.2.0
5 months ago
0.1.0-a9836b7d-20250509103313
6 months ago
0.1.0
9 months ago
0.1.0-5351cd82-20250116121123
9 months ago
0.1.0-3c662842-20241213132247
11 months ago