6.7 KiB
@vercel/flags
2.7.0
Minor Changes
-
fb50709: Adds support for using feature flags in Pages Router.
The same feature flag declared for App Router can now also be used in Pages Router. Feature flags need to be used server-side.
Note that your implementation of the actual feature flag needs to be compatible with Pages Router if you plan on using it inside of Pages Router. This means you can not call functions like
headers()andcookies()which are not available in Pages Router. You can instead rely on theheadersandcookiesarguments passed to yourdecidefunction asdecide({ headers, cookies }).Dynamic usage example
export async function getServerSideProps({ req }) { const showFreeDeliveryBanner = await showFreeDeliveryBannerFlag(req); return { props: { showFreeDeliveryBanner } }; }Precomputed usage example
import { bannerFlags, showFreeDeliveryBannerFlag } from './flags'; import type { GetStaticPaths, GetStaticProps, InferGetStaticPropsType, } from 'next'; import { unstable_generatePermutations as generatePermutations } from '@vercel/flags/next'; export const getStaticPaths = (async () => { const codes = await generatePermutations(bannerFlags); return { paths: codes.map((code) => ({ params: { code } })), fallback: 'blocking', }; }) satisfies GetStaticPaths; export const getStaticProps = (async (context) => { const showFreeDeliveryBanner = await showFreeDeliveryBannerFlag( context.params!.code as string, bannerFlags, ); return { props: { showFreeDeliveryBanner } }; }) satisfies GetStaticProps<{ showFreeDeliveryBanner: boolean }>; -
87503b6: Return
createdAtandupdatedAtas part of the provider data for those that support it
2.6.3
Patch Changes
- 69f8df0: use defaultValue when an async decide function throws
- 65d3d73: add MIT license
2.6.2
Patch Changes
-
80e0737: Add Next.js 15 compatibility.
Uses the async versions of
headersandcookiesto avoid warnings during development.
2.6.1
Patch Changes
- 9c379a8: add pagination to LaunchDarkly provider
2.6.0
Minor Changes
- 7b9aa17: evaluate flags once per request only by reusing the result
- b049c26: add SvelteKit support
Patch Changes
-
c12f4d4: Deprecates
FlagsReporterandinjectFlags.Web Analytics now automatically detects flags present in the DOM, so these are no longer necessary.
You can safely remove
FlagsReporterand any calls toinjectFlags. -
1be4799: add no-store to LaunchDarkly provider
2.5.1
Patch Changes
-
3a68cf7: Simplify middleware usage
BREAKING CHANGE:
unstable_precomputenow returns code directlyBefore
const values = await unstable_precompute(precomputeFlags, context); const code = await unstable_serialize(precomputeFlags, values);After
This can now be done in a single function call.
const code = await unstable_precompute(precomputeFlags, context);Other notes
unstable_precomputeconceptually callsunstable_evaluateandunstable_serializeto generate the code.This can also be done manually if you need access to
values:const values = await unstable_evaluate(precomputeFlags, context); const code = await unstable_serialize(precomputeFlags, values);It's also possible to get the value of a specific flag in middleware based on the precomputation:
// flags.ts export const showBanner = flag({ /* ... */ }); export const precomputeFlags = [showBanner /* ... */]; // middleware.ts const code = await unstable_precompute(precomputeFlags, context); const banner = showBanner(code, precomputeFlags);
2.5.0
Minor Changes
- 1003c29: add experimental
@vercel/flags/nextpattern for working with feature flags in Next.js
2.4.0
Minor Changes
- c132300: Add
reportValuefunction to report resolved flags - 5911721: add HappyKit provider
- bf47adb: Provide a the
unstable_getFlagsPropsandunstable_setGlobalFlagsAnalyticsKeysfunctions that can be used to integrate with Vercel Analytics
2.3.0
Minor Changes
- be714bd: add hypertune provider
2.2.1
Patch Changes
- 6f401cc: update README
2.2.0
Minor Changes
- a6883ad: Add Optimizely provider
- af787a9: Include Experiments from Statsig in
getStatsigData
Patch Changes
- ae3f59c: Fix pagination for Statsig provider in
getStatsigData
2.1.2
Patch Changes
- b22ab52: support undefined as authHeader in verifyAccess for Pages Router compatibility
- 155d5ac: make overrideEncryptionMode optional in ApiData type
2.1.1
Patch Changes
- 6b79659: expose ApiData type
2.1.0
Minor Changes
- abae5af: Add verifyAccess to allow skipping encryption on the .well-known/vercel/flags endpoint
2.0.0
Major Changes
-
59befe1: Unify
encryptanddecryptfunctionsBREAKING CHANGE Replace the existing calls to any encrypt* or decrypt* functions like
encryptApiData,encryptOverrides,encryptValuesordecryptApiData,decryptOverrides,decryptValueswithencryptordecrypt
1.1.2
Patch Changes
- 9ff283b: Fix auto-import showing
@vercel/flags/*as option
1.1.1
Patch Changes
- 80a1acc: Fix type export for providers
1.1.0
Minor Changes
- 1f4fb18: Add Statsig and Split providers and update exports in package.json
1.0.0
Major Changes
-
c1e29ea: BREAKING CHANGE:
VERCEL_FLAGS_SECRETenv var has been renamed toFLAGS_SECRET- Rename your
VERCEL_FLAGS_SECRETenvironment variable toFLAGS_SECRETin your project settings on vercel.com - Pull down the latest environment variables using
vercel env pull .env.local
- Rename your
0.2.1
Patch Changes
- 794b711: prevent xss
0.2.0
Minor Changes
- 11a4bb6: add LaunchDarkly provider
0.1.9
Patch Changes
- 1808b9c: fix auto-import in vs code defaulting to wrong path
0.1.8
Patch Changes
- 91f801d: add JSDoc to
FlagDefinitionsType,FlagValuesTypeandFlagOverridesType
0.1.7
Patch Changes
- 1dbfd2c: add jsdoc to origin
0.1.6
Patch Changes
- fa6a6d1: rename types to end with *Types to avoid clash with component names
0.1.5
Patch Changes
- 0e97393: omit src folder from package
0.1.4
Patch Changes
- fe169df: change README wording
0.1.3
Patch Changes
- effd1f6: replace url with origin in FlagDefinition type
0.1.2
Patch Changes
- a4ee199: add main export
- 1a97981: rename data-variant-values to data-variant-state
0.1.1
Patch Changes
- 446f640: rename types
- c1d2bee: fix return value of decryptOverrides