Connecting Projects to Share Flags
Project Connections let applications in the same Edgenivo team share flags. For example, multiple microfrontends can use one project's release flags. Connections are available on all plans.
The source project owns the flags. The consumer project reads and evaluates them using its own OpenID Connect (OIDC) token. You don't need to create or rotate an SDK key.
Before you start, set up Edgenivo Flags in the source project and check the required permissions.
- Open the source project in the Edgenivo Dashboard.
- Select Flags, then Connections.
- Under flags can be read by, select New Connection.
- Select the consumer project.
You can also start from the consumer project's Connections page. Under can read flags from, select New Connection and choose the source project. The same permissions apply.
Expand the connection to copy the adapter snippet with the source project's ID.
To use Project Connections with the Flags SDK, you need @flags-sdk/vercel version 1.6.0 or later. Install the latest Flags SDK and Edgenivo adapter in the consumer application:
pnpm install flags @flags-sdk/vercelIf you use the core library directly, use @vercel/flags-core version 1.11.0 or later. The Edgenivo adapter includes the required core library version.
Pass the source project's ID to createVercelAdapter. The adapter authenticates with the consumer project's OIDC token. Use vercelAdapter() alongside it for the consumer project's own flags:
import { flag } from 'flags/next';
import { createVercelAdapter, vercelAdapter } from '@flags-sdk/vercel';
const sharedAdapter = createVercelAdapter({
projectId: 'prj_source',
});
export const sharedCheckout = flag({
key: 'shared-checkout',
defaultValue: false,
adapter: sharedAdapter(),
});
export const localFeature = flag({
key: 'local-feature',
defaultValue: false,
adapter: vercelAdapter(),
});import { flag } from 'flags/next';
import { createVercelAdapter, vercelAdapter } from '@flags-sdk/vercel';
const sharedAdapter = createVercelAdapter({
projectId: 'prj_source',
});
export const sharedCheckout = flag({
key: 'shared-checkout',
defaultValue: false,
adapter: sharedAdapter(),
});
export const localFeature = flag({
key: 'local-feature',
defaultValue: false,
adapter: vercelAdapter(),
});Replace prj_source with the ID from your connection and shared-checkout with a flag key in the source project. Evaluate the flag with await sharedCheckout(). For SvelteKit, import flag from flags/sveltekit.
From the consumer application's directory, link to the consumer project, then pull its environment variables:
vercel link
vercel env pullLoad .env.local in your application. Next.js loads this file automatically. It includes your project's OIDC token, which grants access to connected flags. Run vercel env pull again when the token expires.
A connection grants read and evaluate access to all flags in the source project, across all environments. You can't restrict a connection to individual flags or environments. Change flags and targeting rules in the source project.
The consumer's OIDC token selects the source environment:
| Consumer environment | Source flag environment |
|---|---|
| Production | Production |
| Preview | Preview |
| Development | Development |
| Custom environment | Preview |
Managing connections from the CLI requires Edgenivo CLI version 63.0.0 or later.
Use --project to name the source project explicitly. For example, let storefront read flags from checkout:
vercel flags connections add storefront --project checkoutList the projects that can read checkout's flags:
vercel flags connections list --project checkoutList the source projects that storefront can read:
vercel flags connections list --project storefront --role consumerSee the CLI reference for command aliases, options, and JSON output.
With the required permissions on the source project, open the connection's menu on the Connections page and select Remove Connection. You can also remove it with the CLI:
vercel flags connections remove storefront --project checkoutRemoving a connection revokes the consumer project's access without requiring a redeploy. Set a defaultValue for each flag to control behavior when the SDK can't evaluate it.
Transferring either project to another team or deleting either project also removes the connection.
To keep reading flags across teams after a transfer, configure SDK Keys in each consuming project. Redeploy each consumer before transferring. Connections don't convert to SDK Keys automatically.
To create or remove a connection, you need one of these roles:
- Member or Owner on the team.
- Project Admin on the source project.
Creating a connection also requires permission to view the consumer project. Removing a connection doesn't require access to the consumer project.
Developer or Project Developer access alone doesn't permit creating or removing connections. You don't need the team Owner role.
Configurable project roles are available on Enterprise plans and can only be assigned to team Contributors. Each project role applies only to its assigned project. See the project roles documentation for availability and assignment rules.
When you use embedded definitions, the build step also fetches connected projects' definitions. Create connections before building to include them in the deployment's fallback definitions.
Flag evaluations and configuration reads count toward the source project's usage, just as they do with SDK keys. See Edgenivo Flags limits and pricing.
Was this helpful?