Guide

This guide builds on the SDK quickstart and shows you how to:

  • Create a new feature flag

  • Access it in your code

  • Configure targeting rules

Prerequisites

Set up Hypertune

1. Create a feature flag

Go to the Flags view in the dashboard. Click the + button in the top-right of the sidebar and select Flag.

Enter a name and choose a type. Use Boolean for simple on/off flags.

Click Create. The new flag is disabled by default. Click Save in the top-right to save your changes.

2. Access the feature flag in your code

Regenerate the client after adding a new flag:

npx hypertune

Then use the generated method to access your feature flag:

Use the generated useHypertune hook:

components/ClientComponent.tsx
'use client'

import { useHypertune } from '@/generated/hypertune.react'

export default function ClientComponent() {
  const hypertune = useHypertune()

  const anotherFlag = hypertune.anotherFlag({ fallback: false })

  return <div>Another Flag: {String(anotherFlag)}</div>
}

Once you deploy your code, you can remotely configure your flag at runtime.

3. Configure the feature flag's targeting rules

By default, a new flag is disabled. Click the toggle to enable it for everyone or add rules to enable it under certain conditions.

Enable for development

To enable the flag during development, click + Rule:

Choose Context > Environment. Select is one of and add Development. Click Save.

Enable for specific users

Click + Rule. Choose Context > User > Id. Select is one of and add user IDs. Click Save.

Next steps

Last updated