This site is not affiliated with or endorsed by Vercel, Inc. Read the docs, then deploy or run each experiment yourself.
Routing

Maintenance / Canary Lab

Env or Global Config kill switch plus percentage canary cookie assignment with two UI variants and counters.

Run this experiment yourself

Demos are not embedded on this site. Deploy a standalone copy on Vercel or run the experiment app locally.

Local development

cd apps/experiments/maintenance-canary-lab
pnpm install
pnpm dev

Then open http://localhost:3010.

This is an experimental demo. Use it as a starting point for your own projects.

Combine a maintenance kill switch (MAINTENANCE_MODE env, Global Config-ready) with sticky percentage canary assignment. Real proxy.ts rewrites /variant and /maintenance; the demo UI also drives assignment + counters (Redis optional).

Features

  • Env kill switch - maintenance rewrite
  • Percentage canary with sticky cookie
  • Two concrete UI variants (control / canary)
  • Hit counters in Redis or memory
  • Simulator controls in the demo shell

API Reference

GET /api/canary

Env snapshot + counters.

POST /api/canary

Actions: assign, hit, snapshot with optional maintenanceMode / canaryPercent.

Implementation Details

demo.tsx
logic.ts
logic.test.ts

assignVariant in logic.ts is pure and tested. proxy.ts applies maintenance rewrites and sticky ve-canary cookies for /variant.

Use Cases

  • Emergency maintenance pages
  • Percentage UI rollouts
  • Sticky cohort assignment

Limitations

  • Counters without Redis are per-instance.
  • Global Config is documented/optional - env drives the included proxy.
  • Canary percent uses Math.random on first assignment only.

Use in your project

Deploy or copy apps/experiments/maintenance-canary-lab/ and adapt the Route Handlers and pure helpers in logic.ts. Keep honest fallbacks when optional services are missing.

Deployment

Deploy on Vercel

Local Development

cd apps/experiments/maintenance-canary-lab
pnpm install
pnpm dev

Open http://localhost:3010

Configuration

VariableRequiredPurpose
MAINTENANCE_MODENoKill switch
CANARY_PERCENTNo0–100 canary share
GLOBAL_CONFIGNoOptional store
UPSTASH_REDIS_REST_URLNoOptional counters
UPSTASH_REDIS_REST_TOKENNoOptional counters

Vercel / Next.js Features Used

  • proxy.ts
  • Rewrites
  • Cookies
  • Upstash Redis (optional)

Next Steps

  • Explore related labs from the registry relatedSlugs
  • Harden secrets, auth, and input limits before production
  • Prefer platform primitives when you outgrow demo patterns

On this page