Skip to main content
The Next.js SDK (@clubedge/feature-flags-nextjs) provides a FeatureFlagsProvider and useFeatureFlag() hook for Next.js applications. It supports both the App Router (client components with hooks) and Server Components (direct isEnabled() calls during SSR/SSG).

Requirements

  • Next.js 14+
  • React 18+

Installation

App Router (client components)

1. Create a client and provider

2. Wrap your root layout

3. Use the hook in a client component

Server Components (SSR / SSG)

For server-side evaluation, instantiate the client directly and call isEnabled() — no provider needed:

Pages Router

Security

The NEXT_PUBLIC_FF_SDK_KEY is bundled into the browser. Use it only for non-sensitive flags. For sensitive flags, use Server Components with FF_SDK_KEY (server-only) or the Node.js SDK.

Next steps