/vercel-testing

playing around with vercel

Primary LanguageTypeScript

name slug description framework useCase css deployUrl demoUrl relatedTemplates
Feature Flag Apple Store
feature-flag-apple-store
This template uses Edge Config as fast storage to control whether an store is open or closed.
Next.js
Edge Functions
Edge Middleware
Edge Config
Tailwind
maintenance-page
ab-testing-simple
nextjs-boilerplate

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

Deploy the example using Vercel:

Deploy with Vercel

Clone and Deploy

Execute create-next-app with pnpm to bootstrap the example:

pnpm 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:

pnpm dev

Deploy it to the cloud with Vercel (Documentation).

Opening / Closing the Store using the Dashboard

You can control whether the store is open or not by changing the value of featureFlagsAppleStore_storeClosed using the Edge Config Dashboard.

Opening / Closing the Store using API Routes

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 using the routes 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.