# Provide targeting attributes

Hypertune lets you define targeting attributes at the:

* `root` level
* individual flag level

And provide them during:

* SDK initialization
* local flag evaluation
* a mix of both

## Provide targeting attributes during SDK initialization

To provide targeting attributes during SDK initialization, [use an initialization query](/sdk-reference/initialization.md#use-an-initialization-query).

## Provide targeting attributes during local flag evaluation

On the server, you'll typically provide targeting attributes when locally evaluating the `root` flag, passing it the `context` argument you defined in your [schema](/concepts/schema.md). You'll get back the `Root` SDK node which will have type-safe methods to evaluate all your individual flags. In React, this is managed by the generated `<HypertuneProvider>` component.

{% tabs %}
{% tab title="React" %}
{% code title="src/components/AppHypertuneProvider.tsx" %}

```tsx
import { HypertuneProvider } from '../generated/hypertune.react'

export default function AppHypertuneProvider({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <HypertuneProvider
      createSourceOptions={{
        token: import.meta.env.VITE_HYPERTUNE_TOKEN!,
      }}
      rootArgs={{
        context: {
          environment:
            process.env.NODE_ENV === 'development'
              ? 'development'
              : 'production',
          user: {
            id: 'e23cc9a8-0287-40aa-8500-6802df91e56a',
            name: 'Example User',
            email: 'user@example.com',
          },
        },
      }}
    >
      {children}
    </HypertuneProvider>
  )
}
```

{% endcode %}
{% endtab %}

{% tab title="Node.js" %}
{% code title="src/lib/getHypertune.ts" %}

```typescript
import { createSource } from '../generated/hypertune'

const hypertuneSource = createSource({
  token: process.env.HYPERTUNE_TOKEN!,
})

export default async function getHypertune() {
  // Get flag updates in serverless environments
  // await hypertuneSource.initIfNeeded();

  return hypertuneSource.root({
    args: {
      context: {
        environment:
          process.env.NODE_ENV === 'development'
            ? 'development'
            : 'production',
        user: {
          id: 'e23cc9a8-0287-40aa-8500-6802df91e56a',
          name: 'Example User',
          email: 'user@example.com',
        },
      },
    },
  })
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Provide flag-specific targeting attributes

You can also provide [flag-specific targeting attributes](/concepts/schema.md#flag-specific-targeting-attributes) when evaluating individual flags:

```typescript
hypertune.upgradeCopy({ args: { selectedPlan }, fallback: "Upgrade your plan" });
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hypertune.com/sdk-reference/provide-targeting-attributes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
