Skip to main content

SDK Concepts

FlagSync SDKs enable feature management across platforms:

Setup

Learn the prerequisites and initialization process for SDKs.

SDK Types

Explore client-side and server-side SDK differences.

Flag Evaluation

Understand how FlagSync evaluates flags for users.

FlagSync CLI

Learn how FlagSync CLI provides type safety in your application.

SDK Best Practices

The FlagSync CLI generates TypeScript types from your feature flag config.
  • IntelliSense autocompletion (e.g., client.flag(...), useFlag(...))
  • Compile-time safety.
  • Confidence that your code matches your flags.

User Context Best Practices

When defining the user context for flag evaluations, always provide a unique and persistent key in the FsUserContext object to ensure accurate billing and consistent flag behavior:
  • Billing Impact: FlagSync tracks monthly active users (MAUs) based on unique key values, which are limited by your pricing tier. Non-unique or non-persistent keys (e.g., hardcoding 'anonymous' or generating a new ID per request) can undercount or overcount MAUs, affecting billing accuracy.
  • Functionality Impact: During percentage rollouts, FlagSync uses the user context for deterministic hashing to ensure the same user receives consistent flag values across sessions. Non-persistent keys cause inconsistent flag evaluations, disrupting rollout behavior.
Avoid hardcoding key values like 'anonymous' or generating a new ID on every request (e.g., calling nanoid() without persistence). Instead, use a persistent identifier, such as a cookie for unauthenticated users (e.g., visitor-id), to ensure accurate MAU tracking and consistent flag evaluations.