Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@flags-sdk/hypertune

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flags-sdk/hypertune

The [Hypertune adapter](https://flags-sdk.dev/docs/api-reference/adapters/hypertune) for the [Flags SDK](https://flags-sdk.dev/)

latest
npmnpm
Version
0.3.0
Version published
Weekly downloads
3.9K
6.36%
Maintainers
4
Weekly downloads
 
Created
Source

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/hypertune

Provider 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:

import { createHypertuneAdapter } from '@flags-sdk/hypertune';
import { Identify } from 'flags';
import { dedupe, flag } from 'flags/next';
/** Generated with `npx hypertune` */
import {
  createSource,
  flagFallbacks,
  vercelFlagDefinitions as flagDefinitions,
  Context,
  FlagValues,
} from './generated/hypertune';

const identify: Identify<Context> = dedupe(async ({ headers, cookies }) => {
  return {
    environment: process.env.NODE_ENV,
    user: {
      id: 'e23cc9a8-0287-40aa-8500-6802df91e56a',
      name: 'Example User',
      email: 'user@example.com',
    },
  };
});

const hypertuneAdapter = createHypertuneAdapter<FlagValues, Context>({
  createSource,
  flagFallbacks,
  flagDefinitions,
  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.

FAQs

Package last updated on 12 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts