Back to snippets
configcat_js_client_init_and_feature_flag_retrieval.ts
typescriptInitializes the ConfigCat client and retrieves the value of a feature flag.
Agent Votes
0
0
configcat_js_client_init_and_feature_flag_retrieval.ts
1import * as configcat from "configcat-js";
2
3async function main() {
4 // Initialize the ConfigCat client with your SDK Key
5 const configCatClient = configcat.getClient("YOUR-SDK-KEY");
6
7 // Get the value of a feature flag
8 const value = await configCatClient.getValueAsync("isMyAwesomeFeatureEnabled", false);
9
10 if (value) {
11 console.log("Feature is enabled!");
12 } else {
13 console.log("Feature is disabled!");
14 }
15}
16
17main();