Skip to content

Feature Flag Apple Store

This template uses Edge Config as fast storage to control whether an store is open or closed.

Feature Flag Apple Store

This template uses Edge Config as fast storage to control whether the store is open or closed.

Demo

https://edge-functions-feature-flag-apple-store.vercel.app/

How to Use

You can choose from one of the following two methods to use this repository:

One-Click Deploy

After setting up your environment variables, deploy the example using Vercel:

Clone and Deploy

Execute create-next-app with npm or Yarn to bootstrap the example:

npx create-next-app --example https://github.com/vercel/examples/tree/main/edge-middleware/feature-flag-apple-store
# or
yarn create next-app --example https://github.com/vercel/examples/tree/main/edge-middleware/feature-flag-apple-store
Set up environment variables

Copy the .env.example file in this directory to .env.local (which will be ignored by Git):

cp .env.example .env.local

This example requires you to set up an Edge Config and store its connection string in the EDGE_CONFIG environment variable. Fill the Edge Config you create with this content:

{ "featureFlagsAppleStore_storeClosed": true }

Next, run Next.js in development mode:

npm install
npm run dev

# or

yarn
yarn dev

Deploy it to the cloud with Vercel (Documentation).

Opening / Closing the Store

You can control whether the store is open or not by changing the value of featureFlagsAppleStore_storeClosed. Use API routes or Vercel's Edge Config UI to update Edge Config.

Note that you need to provide your own TEAM_ID_VERCEL and AUTH_BEARER_TOKEN environment variables in .env.local if you want to open or close the store as shown below.

To open the store go to:

http://localhost:3000/api/store/open

To close the store go to:

http://localhost:3000/api/store/close

Alternatively you can use the Edge Config UI in your Vercel dashboard to update the featureFlagsAppleStore_storeClosed value directly.

Feature Flag Apple Store

This template uses Edge Config as fast storage to control whether an store is open or closed.

Feature Flag Apple Store

This template uses Edge Config as fast storage to control whether the store is open or closed.

Demo

https://edge-functions-feature-flag-apple-store.vercel.app/

How to Use

You can choose from one of the following two methods to use this repository:

One-Click Deploy

After setting up your environment variables, deploy the example using Vercel:

Clone and Deploy

Execute create-next-app with npm or Yarn to bootstrap the example:

npx create-next-app --example https://github.com/vercel/examples/tree/main/edge-middleware/feature-flag-apple-store
# or
yarn create next-app --example https://github.com/vercel/examples/tree/main/edge-middleware/feature-flag-apple-store
Set up environment variables

Copy the .env.example file in this directory to .env.local (which will be ignored by Git):

cp .env.example .env.local

This example requires you to set up an Edge Config and store its connection string in the EDGE_CONFIG environment variable. Fill the Edge Config you create with this content:

{ "featureFlagsAppleStore_storeClosed": true }

Next, run Next.js in development mode:

npm install
npm run dev

# or

yarn
yarn dev

Deploy it to the cloud with Vercel (Documentation).

Opening / Closing the Store

You can control whether the store is open or not by changing the value of featureFlagsAppleStore_storeClosed. Use API routes or Vercel's Edge Config UI to update Edge Config.

Note that you need to provide your own TEAM_ID_VERCEL and AUTH_BEARER_TOKEN environment variables in .env.local if you want to open or close the store as shown below.

To open the store go to:

http://localhost:3000/api/store/open

To close the store go to:

http://localhost:3000/api/store/close

Alternatively you can use the Edge Config UI in your Vercel dashboard to update the featureFlagsAppleStore_storeClosed value directly.

Unleash New Possibilities

Deploy your app on Vercel and unlock its full potential

Try Vercel Free