Simple flags — environment variables or config. Complex scenarios — dedicated services: LaunchDarkly, Flagsmith, GrowthBook, Unleash. These support targeting by user_id, country, plan, and more.
A feature flag is a temporary construct. Remove flags after full rollout, or the codebase will turn into a maze of conditionals.