> ## Documentation Index
> Fetch the complete documentation index at: https://docs.grantiva.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Feature Flags Quick Start

> Toggle features remotely in your iOS app without app updates

## Prerequisites

* Grantiva SDK installed ([Installation](/sdk/installation))
* Device attestation working ([Quick Start](/quickstart)) — flag endpoints authenticate with the attestation JWT, so call `validateAttestation()` before reading flags (in the Simulator, use [API key mode](/simulator-setup) instead)
* At least one flag created in the [dashboard](https://grantiva.io/dashboard)

## 1. Create a flag in the dashboard

Go to **Feature Flags** in the dashboard sidebar and create a flag:

* **Key**: `dark_mode`
* **Type**: Boolean
* **Value**: `true` (production), `false` (staging)

## 2. Read flags in your app

```swift theme={null}
let darkMode = try await grantiva.flags.boolValue(for: "dark_mode", default: false)

if darkMode {
    enableDarkMode()
}
```

## 3. All flag types

```swift theme={null}
// Boolean
let enabled = try await grantiva.flags.boolValue(for: "new_feature", default: false)

// String
let theme = try await grantiva.flags.stringValue(for: "theme", default: "light")

// Integer
let maxUploads = try await grantiva.flags.intValue(for: "max_uploads", default: 5)

// Double
let threshold = try await grantiva.flags.doubleValue(for: "risk_threshold", default: 0.5)

// All flags at once
let allFlags = try await grantiva.flags.getFlags()
```

## 4. Environments

Flags can have different values per environment:

```swift theme={null}
// Switch to staging
grantiva.flags.environment = .staging
let flags = try await grantiva.flags.getFlags(forceRefresh: true)

// Back to production
grantiva.flags.environment = .production
```

## 5. Cache control

Flags are cached for 5 minutes by default:

```swift theme={null}
// Change cache duration
grantiva.flags.cacheTTL = 60  // 1 minute

// Force refresh
grantiva.flags.refresh()
let fresh = try await grantiva.flags.getFlags()
```

## SwiftUI example

```swift theme={null}
struct ContentView: View {
    @State private var showNewFeature = false
    let grantiva: Grantiva

    var body: some View {
        VStack {
            Text("My App")
            if showNewFeature {
                NewFeatureView()
            }
        }
        .task {
            showNewFeature = (try? await grantiva.flags.boolValue(
                for: "new_feature",
                default: false
            )) ?? false
        }
    }
}
```

## Tier limits

| Tier       | Max flags |
| ---------- | --------- |
| Free       | 10        |
| Pro        | 50/app    |
| Business   | 200/app   |
| Enterprise | Unlimited |

## Next steps

* [Full Feature Flags SDK reference](/sdk/feature-flags)
* [Feature Flags API reference](/api-reference/flags/get-flags)
