Comment on page
Type-safe client generation
SDKs come with a CLI tool to auto-generate a client so you can access your flags with end-to-end type-safety. This ensures typos in flag names or incorrectly passed targeting attributes can be caught at build-time rather than runtime. It also improves the developer experience with code completion, "find all references" and type-safe flag clean up.
To generate a client, first define the following environment variables in your
.env
file:NEXT_PUBLIC_HYPERTUNE_TOKEN=token
HYPERTUNE_OUTPUT_FILE_PATH=generated/generated.ts
Replace
token
with your project token which you can find in the Settings tab of your project.Then run:
npm
yarn
pnpm
npx hypertune
yarn hypertune
pnpm hypertune
You can customize client generation with the following environment variables:
# Set whether Hypertune should include a build-time fallback of your flag logic
HYPERTUNE_INCLUDE_FALLBACK=true
# Set whether Hypertune should include your token in the generated code
HYPERTUNE_INCLUDE_TOKEN=true
# Set where Hypertune should find your query file path
HYPERTUNE_QUERY_FILE_PATH=hypertune.graphql
You can also pass these as command-line arguments. To see all available options, run:
npm
yarn
pnpm
npx hypertune --help
yarn hypertune --help
pnpm hypertune --help
This will output:
Usage:
$ hypertune
Commands:
Generate Hypertune files for your project
For more info, run any command with the `--help` flag:
$ hypertune --help
Options:
--token [value] Project token
--queryFilePath [value] File path to the GraphQL initialization query (default: hypertune.graphql)
--outputFilePath [value] Where to write the generated file (default: generated/generated.ts)
--includeToken Include your token in the generated code (default: false)
--includeFallback Embed a snapshot of your configuration logic in the generated code so the SDK can reliably, locally initialize first, before fetching the latest logic from the server, and can work even if the server is unreachable (default: false)
-h, --help Display this message
-v, --version Display version number
Last modified 1mo ago