# 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](https://docs.hypertune.com/initialization#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](https://docs.hypertune.com/concepts/schema). 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](https://docs.hypertune.com/concepts/schema#flag-specific-targeting-attributes) when evaluating individual flags:

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