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

# Create a boolean flag

> Define an on/off flag in TypeScript or Go, push it, evaluate it locally, and turn it on in the dashboard.

## Overview

In this guide you add a boolean flag, `new-checkout`, in TypeScript or Go, push it, branch on it in code, and turn it on from the dashboard.

You need the `shipd` CLI signed in (`shipd login`) and an SDK client. See the [Quickstart](/quickstart.md) if you have neither.

## Steps

**1. Define the flag**

```ts TypeScript theme={null}
// shipd.config.ts
import { defineFlags } from "shipdit/config";

export default defineFlags({
  "new-checkout": {
    type: "boolean",
    default: false,
    description: "Redesigned checkout flow",
    tags: ["checkout"],
  },
});
```

```go Go theme={null}
// Entries inside config.ShipdConfig (import github.com/alasti-company/useshipd.com/sdks/go/config).
"new-checkout": {Type: "boolean", Default: false,
    Description: "Redesigned checkout flow", Tags: []string{"checkout"}},
```

For Go, add definitions to `Config` in `shipd.config.go`, then run `shipd push`. See [Define flags in code](/config-as-code/define-flags.md#go-definitions) for the complete file.

**2. Push it**

```bash theme={null}
shipd push --project web-app --env production
```

The flag is created in every environment of the project. In the environment you push to, it is enabled and its **Fallthrough** serves the `default` (`false`). Push also regenerates TypeScript types or Go accessors according to your [project settings](/reference/config.md#project-settings-file).

**3. Evaluate it**

```ts TypeScript theme={null}
// src/checkout.ts
import { shipd } from "./lib/shipd";

export function renderCheckout(userId: string) {
  if (shipd.isEnabled("new-checkout", { userId })) {
    return renderNewCheckout();
  }
  return renderLegacyCheckout();
}
```

```go Go theme={null}
// checkout.go
if client.IsEnabled("new-checkout", shipd.EvaluationContext{UserID: userID}) {
    return renderNewCheckout()
}
return renderLegacyCheckout()
```

In React:

```tsx src/components/checkout.tsx theme={null}
const on = useFlag("new-checkout");
```

Pass `"new-checkout": false` in the client's `defaults` so the flag stays off before the first snapshot arrives. See [`isEnabled`](/reference/sdk#isenabled).

**4. Turn it on**

In the [dashboard](https://app.useshipd.com), open the project, click `new-checkout`, and select the environment. Then either:

* set **Fallthrough** to `true` to turn it on for everyone, or
* click **Add rule** to turn it on for some users ([by attribute](/flags/targeting.md) or [by percentage](/flags/percentage-rollouts.md)).

Click **Save environment**. Running SDK clients pick up the change on their next snapshot refresh.

> [!NOTE]
>
> `shipd push` sets **Fallthrough** in the target environment back to the config `default` when they differ. After you change **Fallthrough** in the dashboard, update `default` in your flag definitions (or run `shipd pull`) so the next push doesn't revert it. See [Push, pull, and diff](/config-as-code/sync.md).

## Create it without a config file

```bash theme={null}
shipd flags create --key new-checkout --type boolean --description "Redesigned checkout flow"
```

Prefer `defineFlags` and `shipd push` so the repository stays the source of truth. See [CLI reference](/reference/cli.md).

## Next

* [Target users by attribute](/flags/targeting.md)
* [Roll out a flag to a percentage of users](/flags/percentage-rollouts.md)
* [Turn a feature off immediately](/flags/kill-switch.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.