NEXT_PUBLIC_FLAGGISH_CLIENT_KEY=your-client-key
# Optional
NEXT_PUBLIC_FLAGGISH_ENV=production
NEXT_PUBLIC_FLAGGISH_API_URL=https://flags.example.com
NEXT_PUBLIC_FLAGGISH_REACH=falseOnly the client key is required. In Next.js, the NEXT_PUBLIC_ names cover both the server and the browser, so they’re usually all you need.
All variables
| Variable | Sets | Values |
|---|---|---|
| FLAGGISH_CLIENT_KEY | clientKey | Your client key, from Settings › API keys |
| NEXT_PUBLIC_FLAGGISH_CLIENT_KEY | clientKey | The same, readable in the browser |
| FLAGGISH_SECRET_KEY | secretKey | Your secret key, from Settings › API keys. Server only, for list groups. There is no NEXT_PUBLIC_ version |
| FLAGGISH_ENV | env | production or development, any case |
| NEXT_PUBLIC_FLAGGISH_ENV | env | The same, readable in the browser |
| FLAGGISH_API_URL | apiUrl | The API base URL, for a self-hosted API |
| NEXT_PUBLIC_FLAGGISH_API_URL | apiUrl | The same, readable in the browser |
| FLAGGISH_REACH | reach | false or 0 turn reach off; true or 1 turn it on |
| NEXT_PUBLIC_FLAGGISH_REACH | reach | The same, readable in the browser |
| NODE_ENV | env, as a last resort | production reads Production flags; anything else reads Development |
The secret key
FLAGGISH_SECRET_KEY is the one variable that must never be readable in a browser. Set it in your server’s environment only, and never give it a NEXT_PUBLIC_ name: the SDK doesn’t read one, and Next.js would write it into your browser code. It’s only needed for list groups. An empty value counts as not set.
Which one wins
For each setting, the SDK uses the first of these that’s set:
- the option you pass in code, such as
envorclientKey - the plain variable, such as
FLAGGISH_ENV - the
NEXT_PUBLIC_variable, such asNEXT_PUBLIC_FLAGGISH_ENV - the default: the
NODE_ENVrule forenv, the Flaggish API forapiUrl, and on forreach
An empty variable counts as not set. A value the SDK doesn’t recognise for FLAGGISH_ENV or FLAGGISH_REACH is ignored, and it moves on to the next one.
Server and browser
Next.js only exposes NEXT_PUBLIC_ variables to browser code. So FLAGGISH_SECRET_KEY, FLAGGISH_ENV, FLAGGISH_API_URL and FLAGGISH_REACH only apply on the server, and client components fall back to the defaults.
- To set something for both sides, set the
NEXT_PUBLIC_name. - To set it for the server only, set the plain name.
- To set it for one provider, pass it as a prop to
FlaggishProviderorFlaggishServerProvider.
Next.js writes NEXT_PUBLIC_ values into the browser code when it builds, so rebuild after you change one.
With FlaggishServerProvider, set the client key and environment with the NEXT_PUBLIC_ names. If you set only FLAGGISH_ENV, the server reads that environment but the browser reports reach for the environment its own NODE_ENV implies, so those reach events are dropped. If you set only FLAGGISH_CLIENT_KEY, the browser has no key: it sends no reach, and if the server’s fetch failed, the browser can’t fetch the flags itself.
The Next.js server helpers
getFlag, getFlags and getFlaggishConfig take no options, so environment variables are the only way to configure them, including FLAGGISH_SECRET_KEY. For example, FLAGGISH_REACH=false is the way to turn reach off for them.
Node
Plain Node has no browser, so use the plain names:
FLAGGISH_CLIENT_KEY=your-client-key
FLAGGISH_ENV=production
# Optional, for list groups
FLAGGISH_SECRET_KEY=your-secret-keyThe SDK reads process.env directly. It doesn’t load .env files, so load them the way you normally do.