Feature Flags Configuration

Control feature availability and gradual rollouts using feature flags in the Next.js Drizzle SaaS Kit.

Feature flags allow you to enable or disable features without changing the codebase.

We use environment variables as an easy, no frills way to control the feature flags - as you can easily override the default behavior by setting the environment variable instead of having to change any code.

The current feature flags are defined in the apps/web/config/feature-flags.config.ts file.

apps/web/config/feature-flags.config.ts

import * as z from 'zod';
const FeatureFlagsSchema = z.object({
enableAccountDeletion: z.boolean(),
enableOrganizationDeletion: z.boolean(),
enableOrganizations: z.boolean(),
enablePersonalAccountBilling: z.boolean(),
enableOrganizationsBilling: z.boolean(),
allowUserToCreateOrganization: z.boolean(),
showAccountSwitcher: z.boolean(),
enableThemeToggle: z.boolean(),
enableVersionUpdater: z.boolean(),
enableCustomRoles: z.boolean(),
maxRolesPerOrganization: z.number().int().positive().optional(),
});

Most flags are automatically derived from your Account Mode configuration. However, the following can be independently configured via environment variables:

NEXT_PUBLIC_ENABLE_THEME_TOGGLE=true
NEXT_PUBLIC_ENABLE_VERSION_UPDATER=false
NEXT_PUBLIC_ENABLE_CUSTOM_ROLES=false
NEXT_PUBLIC_MAX_ROLES_PER_ORGANIZATION=10

Explanation

  • NEXT_PUBLIC_ENABLE_THEME_TOGGLE: Set to false if you want to lock users to a specific theme mode (dark or light) and disallow switching
  • NEXT_PUBLIC_ENABLE_VERSION_UPDATER: Enable to notify users about new versions of the application
  • NEXT_PUBLIC_ENABLE_CUSTOM_ROLES: Enable to allow organizations to create custom roles beyond the default ones
  • NEXT_PUBLIC_MAX_ROLES_PER_ORGANIZATION: Maximum number of custom roles allowed per organization (default: 10)

Next: Navigation Configuration →