A modern e-commerce demo application built to showcase LaunchDarkly's feature flag capabilities at conferences and events.
ToggleStore is a Next.js application that simulates a real-world online store selling LaunchDarkly-themed merchandise. It's designed for live demonstrations of feature management, experimentation, and progressive rollouts using LaunchDarkly.
- ποΈ E-commerce Storefront - Browse products, add to cart, and checkout
- π― Feature Flags - LaunchDarkly integration with 10+ feature flags
- π€ AI Chatbot - AI-powered customer support assistant
- π¨ Modern UI - Dark theme with beautiful gradients
- π± Responsive Design - Works on all devices
- Framework: Next.js 15 with App Router
- Language: TypeScript
- Styling: Tailwind CSS v4
- UI Components: shadcn/ui
- Feature Flags: LaunchDarkly SDK (client-side and server-side)
- Node.js 18+ and npm
- LaunchDarkly account (for feature flags)
- Clone the repository
- Install dependencies:
npm install - Copy
.env.exampleto.env.localand add your LaunchDarkly SDK keys - Run
npm run dev - Open http://localhost:3000
- Sign up at LaunchDarkly
- Create a new project
- Get your SDK keys from Account Settings β Projects β Your Project β Environments
- Add keys to
.env.local:LAUNCHDARKLY_SDK_KEY(server-side)NEXT_PUBLIC_LAUNCHDARKLY_CLIENT_ID(client-side)
ToggleStore includes 10 active feature flags demonstrating various LaunchDarkly capabilities:
- Feature Flagging/Segmentation - Rewards Program
- Progressive Rollout - Referral Program
- Guarded Rollout - Payments & Email Service Upgrades
- Experimentation - Search Algorithm & Promo Banner
- AI Config - Chatbot & Shopping Assistant
- Observability - API Release with error tracking
See FEATURE_FLAGS.md for a complete reference table with all flag keys, variations, and what they control.
ToggleStore/
βββ app/ # Next.js app directory
β βββ api/ # API routes
β βββ page.tsx # Main storefront page
β βββ layout.tsx # Root layout
βββ components/ # React components
β βββ ui/ # shadcn/ui components
β βββ header.tsx # Header with nav and cart
β βββ cart.tsx # Shopping cart drawer
β βββ chatbot.tsx # AI chatbot component
βββ lib/ # Utilities
β βββ launchdarkly/ # LaunchDarkly SDK integration
βββ data/ # Static data
β βββ products.json # Product catalog
βββ public/ # Static assets
import { useFlag } from "@/lib/launchdarkly/client"
export default function MyComponent() {
const rewardsEnabled = useFlag("rewardsProgram", false)
return rewardsEnabled ? <RewardsDialog /> : null
}import { getFlagValue } from "@/lib/launchdarkly/server"
export default async function MyPage() {
const apiRelease = await getFlagValue("apiRelease", context, false)
return apiRelease ? <NewAPI /> : <OldAPI />
}npm run dev # Development server
npm run build # Production build
npm run lint # LintingToggleStore includes a built-in results generator that creates metrics, experiment results, and error logs for LaunchDarkly analytics. This replaces the need for external Python scripts.
Generate results on-demand via API:
# POST request with custom parameters
curl -X POST http://localhost:3000/api/generate-results \
-H "Content-Type: application/json" \
-d '{
"searchAlgorithmUsers": 3000,
"storePromoUsers": 3000,
"aiConfigUsers": 3000,
"aiMonitoringRuns": 1000,
"shoppingAssistantUsers": 1000,
"numErrors": 50
}'
# GET request (uses smaller default values)
curl http://localhost:3000/api/generate-results- Experiment Results: Search algorithm, store promo banner, AI Config experiments
- AI Monitoring: AI interaction metrics (duration, tokens, feedback)
- Shopping Assistant: Agent accuracy and feedback metrics
- Errors & Logs: Simulated errors for observability tracking
- Push code to GitHub
- Import project in Vercel
- Add environment variables
- Deploy
MIT
Built with β€οΈ for LaunchDarkly demonstrations