/sample-nextjs

LaunchDarkly implementation in NextJS with App Router

Primary LanguageJavaScriptApache License 2.0Apache-2.0

README

This is a sample LaunchDarkly implementation on Next.js using App Router with Client and Server components with various rendering strategins.

This is a Next.js project bootstrapped with create-next-app.

Getting Started

Pre-requisites

  • LaunchDarkly account
  • Node >=16.8.x
  • NextJS >=13.x

Setup

  1. Create a feature flag in LaunchDarkly.
flag key flag type description
simple-toggle boolean toggles flag status
  1. Install packages
> npm install
  1. Create a .env file with the following:
LAUNCHDARKLY_SDK_KEY="<LaunchDarkly Server-side SDK Key"
CLIENT_SIDE_ID="<LaunchDarkly Client Side ID>"

Running the demo

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying app/page.js. The page auto-updates as you edit the file.

This project uses next/font to automatically optimize and load Inter, a custom Google Font.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.