|
| 1 | +# Bucket Flags SDK Example |
| 2 | + |
| 3 | +This example uses [Bucket](https://bucket.co) for feature flags with the [Flags SDK](https://flags-sdk.dev) along with the `@flags-sdk/bucket` [Bucket adapter](https://flags-sdk.dev/docs/api-reference/adapters/bucket) and the [Flags Explorer](https://vercel.com/docs/workflow-collaboration/feature-flags/using-vercel-toolbar). |
| 4 | + |
| 5 | +## Demo |
| 6 | + |
| 7 | +[https://flags-sdk-bucket.vercel.app/](https://flags-sdk-bucket.vercel.app/) |
| 8 | + |
| 9 | +## How it works |
| 10 | + |
| 11 | +This demo uses two features on Bucket to control the visibility of two banners on the page. |
| 12 | +Both gates are configured to show/hide each banner 50% of the time. |
| 13 | + |
| 14 | +If you deployed your own and configured the features on Bucket, you can also use the [Flags Explorer](https://vercel.com/docs/workflow-collaboration/feature-flags/using-vercel-toolbar) to enabled/disabled the features. |
| 15 | + |
| 16 | +## Deploy this template |
| 17 | + |
| 18 | +[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fexamples%2Ftree%2Fmain%2Fflags-sdk/bucket&env=FLAGS_SECRET&envDescription=The+FLAGS_SECRET+will+be+used+by+the+Flags+Explorer+to+securely+overwrite+feature+flags.+Must+be+32+random+bytes%2C+base64-encoded.+Use+the+generated+value+or+set+your+own.&envLink=https%3A%2F%2Fvercel.com%2Fdocs%2Fworkflow-collaboration%2Ffeature-flags%2Fsupporting-feature-flags%23flags_secret-environment-variable&project-name=bucket-flags-sdk-example&repository-name=bucket-flags-sdk-example) |
| 19 | + |
| 20 | +### Step 1: Link the project |
| 21 | + |
| 22 | +In order to use the Flags Explorer, you need to link the project on your local machine. |
| 23 | + |
| 24 | +```bash |
| 25 | +vercel link |
| 26 | +``` |
| 27 | + |
| 28 | +Select the project from the list you just deployed. |
| 29 | + |
| 30 | +### Step 2: Pull all environment variables |
| 31 | + |
| 32 | +This allows the Flags SDK and the Flags Explorer to work correctly, by getting additional metadata. |
| 33 | + |
| 34 | +```bash |
| 35 | +vercel env pull |
| 36 | +``` |
| 37 | + |
| 38 | +### Step 3: Create Features |
| 39 | + |
| 40 | +Head over to the [Bucket application](app.bucket.co) and create the features required by this template. |
| 41 | + |
| 42 | +Features: |
| 43 | + |
| 44 | +- `Summer Sale` with the feature key `summer_sale` |
| 45 | +- `Free Shipping` with the feature key `free_delivery` |
| 46 | + |
| 47 | +You can also find the feature keys in the `flags.ts` file. |
| 48 | + |
| 49 | +### Step 4: Configure the Features |
| 50 | + |
| 51 | +Select the `Summer Sale` and `Free Shipping` features and configure them on the Bucket Console. |
| 52 | + |
| 53 | +Create a new rule by clicking on "+ Add Rule" and set the percentage to 50%. |
| 54 | + |
| 55 | +After that, click on "Save". |
0 commit comments