SDK 2.0 decides flags inside your app from a cached config, adds percentage rollouts, and never throws. It also has breaking changes, so plan a short migration.
What changed
- New entry points. React exports live in
@flaggish/sdk/reactand Next.js helpers in@flaggish/sdk/next. The root@flaggish/sdkis the framework-free core. - New functions.
useGetFlags,useFlaggishand the v1getFlagsare replaced byFlaggishProvider,useFlaganduseFlagsin React, andgetFlagandgetFlagson the Next.js server. - Exact flag names. Flag keys are the exact flag names, with no changes. v1 removed spaces from names, so a flag called
new checkoutwasnewcheckout. In v2 it’snew checkout. - No secret key. Use the public client key only.
- A proxy for Next.js. Add
flaggishMiddlewaretoproxy.ts(Next.js 16) ormiddleware.ts(Next.js 14 and 15), so rollouts match between the server and the browser.
Upgrade
Install SDK 2.0
Terminalnpm i @flaggish/sdk@betaUpdate your environment variables
Keep
NEXT_PUBLIC_FLAGGISH_CLIENT_KEYorFLAGGISH_CLIENT_KEY. DeleteFLAGGISH_SECRET_KEY: v2 doesn’t use it, and it doesn’t belong anywhere a browser can see. If you usedNEXT_PUBLIC_FLAGGISH_CLIENT_API_KEY, rename it toNEXT_PUBLIC_FLAGGISH_CLIENT_KEY..env.localNEXT_PUBLIC_FLAGGISH_CLIENT_KEY=your-client-keyFLAGGISH_ENVnow takesproductionordevelopment. See Environment variables.Replace your flag checks
v1import { getFlags, useGetFlags } from '@flaggish/sdk'; // client const { flags, isLoading } = useGetFlags(); const enabled = flags?.newcheckout; // server const serverFlags = await getFlags();v2 · client'use client'; import { useFlag } from '@flaggish/sdk/react'; export const Checkout = () => { const enabled = useFlag('new checkout'); return enabled ? <NewCheckout /> : <OldCheckout />; };v2 · serverimport { getFlag, getFlags } from '@flaggish/sdk/next'; const enabled = await getFlag('new checkout'); const allFlags = await getFlags();Search your code for each flag name. Any name with a space in it needs updating.
Remove error handling around checks
v1 could throw when the API failed or a key was missing. v2 never throws: it falls back to the last flags it had, then your defaults, then
false. Passdefaultsfor flags that should be on when Flaggish can’t be reached. See If Flaggish is down.Check it
Flip a flag in the dashboard. Your app picks up the change within about 30 seconds.
Node
Replace v1’s getFlags() with a client:
import { createFlaggish } from '@flaggish/sdk';
const flaggish = createFlaggish();
const enabled = await flaggish.isEnabled('new checkout', { userId: 'user_123' });See the Node guide.