You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR clean up our Vercel example with improved documentation, updated
dependencies and a simplified example. I am planning to add a more
complete example in a separate PR.
---------
Co-authored-by: Fabian <[email protected]>
This is an example test app to showcase the usage of the Vercel LaunchDarkly
4
-
SDK. This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
4
+
SDK to evaluate a feature flag in a [Route Handler](https://nextjs.org/docs/app/building-your-application/routing/router-handlers) using [Vercel's edge runtime](https://nextjs.org/docs/app/building-your-application/routing/router-handlers#edge-and-nodejs-runtimes). This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
5
+
6
+
Most of the LaunchDarkly-related code can be found in [src/app/api/hello/route.ts](src/app/api/hello/route.ts).
5
7
6
8
## Prerequisites
7
9
8
10
A node environment of version 16 and yarn are required to develop in this repository.
9
-
You will also need the vercel cli installed and a Vercel account to setup
10
-
the test data required by this example. See the [Vercel docs](https://vercel.com/docs/storage/edge-config/get-started) on how to setup your edge config store.
11
+
You will also need the [Vercel CLI](https://vercel.com/docs/cli) installed and a Vercel account to setup
12
+
the test data required by this example. See the [Vercel docs](https://vercel.com/docs/storage/edge-config/get-started) on how to setup your Edge Config store.
13
+
14
+
## Setting up your LaunchDarkly environment
15
+
16
+
For simplicity, we recommend [creating a new LaunchDarkly project](https://docs.launchdarkly.com/home/organize/projects/?q=create+proj) for this example app. After creating a new project, create the following feature flags with Client-side SDK availability:
11
17
12
-
## Usage
18
+
-`test-flag` - (Boolean) - This flag is evaluated in [src/app/api/hello/route.ts](src/app/api/hello/route.ts).
13
19
14
-
1. Follow the [Vercel docs](https://vercel.com/docs/storage/edge-config/get-started) to insert [testData.json](https://github.com/launchdarkly/js-core/blob/main/packages/sdk/vercel/testData.json)to your edge config store.
20
+
After creating your project, you will need to configure the LaunchDarkly Vercel integration to push feature flag data to your Vercel Edge Config. Read the [Vercel integration documentation](https://docs.launchdarkly.com/integrations/vercel/) to set up the integration. Be sure to connect the **Test** environment from the project you created above.
15
21
16
-
2. After completing the guide above, you should have linked this example app to your Vercel project and created an `.env.development.local`.
22
+
## Setting up your development environment
23
+
24
+
1. Copy this directory in a new repository.
25
+
2. Create a new Vercel project based on the new repository.
26
+
3.[Add a new environment variable to your project](https://vercel.com/docs/concepts/projects/environment-variables) named `LD_CLIENT_SIDE_ID` and set it to the LaunchDarkly client-side ID for the **Test** environment in the project you created above.
27
+
4. Follow [Vercel's documentation](https://vercel.com/docs/storage/edge-config/get-started) to connect an Edge Config to your new project.
28
+
5. Run the following command to link your local codebase to your Vercel project:
29
+
30
+
```shell
31
+
vercel link
32
+
```
33
+
34
+
6. Run the following command to sync your projects environment variables in your development environment:
35
+
36
+
```shell
37
+
vercel env pull .env.development.local
38
+
```
17
39
18
-
3. At the root of the js-core repo:
40
+
7. After completing the guide above, you should have linked this example app to your Vercel project and created an `.env.development.local`.
41
+
8. Verify the contents of `.env.development.local` have values for the `LD_CLIENT_SIDE_ID` and `EDGE_CONFIG`.
42
+
9. Run the following command to install all dependencies:
19
43
20
44
```shell
21
-
yarn&& yarn build
45
+
yarn
22
46
```
23
47
24
-
4. Then back in this example folder:
48
+
10. Run the following command to start your development environment:
25
49
26
50
```shell
27
51
yarn dev
28
52
```
29
53
30
-
5. Open [http://localhost:3000/api/hello](http://localhost:3000/api/hello).
54
+
11. Open [http://localhost:3000/api/hello](http://localhost:3000/api/hello).
0 commit comments