{"id":15827534,"url":"https://github.com/configcat/js-sdk","last_synced_at":"2025-04-15T21:06:42.209Z","repository":{"id":33235990,"uuid":"156685444","full_name":"configcat/js-sdk","owner":"configcat","description":"ConfigCat SDK for JavaScript frontend applications. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.","archived":false,"fork":false,"pushed_at":"2025-04-07T10:10:00.000Z","size":11278,"stargazers_count":30,"open_issues_count":0,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-15T21:06:26.588Z","etag":null,"topics":["angular","angularjs","configcat","configuration","configuration-management","feature-flag","feature-flags","feature-toggle","feature-toggles","featureflags","javascript","react","remote-config","typescript"],"latest_commit_sha":null,"homepage":"https://configcat.com/docs/sdk-reference/js","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/configcat.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-11-08T09:53:12.000Z","updated_at":"2025-04-07T10:10:03.000Z","dependencies_parsed_at":"2024-03-21T13:44:31.928Z","dependency_job_id":null,"html_url":"https://github.com/configcat/js-sdk","commit_stats":{"total_commits":314,"total_committers":18,"mean_commits":"17.444444444444443","dds":0.5509554140127388,"last_synced_commit":"a7f9b33f562526539bd3e087a66704592dea6968"},"previous_names":[],"tags_count":86,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/configcat%2Fjs-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/configcat%2Fjs-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/configcat%2Fjs-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/configcat%2Fjs-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/configcat","download_url":"https://codeload.github.com/configcat/js-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249153943,"owners_count":21221330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","angularjs","configcat","configuration","configuration-management","feature-flag","feature-flags","feature-toggle","feature-toggles","featureflags","javascript","react","remote-config","typescript"],"created_at":"2024-10-05T10:06:48.720Z","updated_at":"2025-04-15T21:06:42.193Z","avatar_url":"https://github.com/configcat.png","language":"TypeScript","readme":"# ConfigCat SDK for JavaScript frontend applications\nhttps://configcat.com\n\nConfigCat SDK for JavaScript provides easy integration for your application to ConfigCat.\n\n## About\n\nManage features and change your software configuration using \u003ca href=\"https://configcat.com\" target=\"_blank\"\u003eConfigCat feature flags\u003c/a\u003e\n, without the need to re-deploy code. A \u003ca href=\"https://app.configcat.com\" target=\"_blank\"\u003e10 minute trainable Dashboard\u003c/a\u003e \nallows even non-technical team members to manage features directly. Deploy anytime, release when confident. \nTarget a specific group of users first with new ideas. Supports A/B/n testing and soft launching.\n\nConfigCat is a \u003ca href=\"https://configcat.com\" target=\"_blank\"\u003ehosted feature flag service\u003c/a\u003e. Manage feature toggles across frontend, backend, mobile, desktop apps. \u003ca href=\"https://configcat.com\" target=\"_blank\"\u003eAlternative to LaunchDarkly\u003c/a\u003e. Management app + feature flag SDKs.\n\n[![JS CI](https://github.com/configcat/js-sdk/actions/workflows/js-ci.yml/badge.svg?branch=master)](https://github.com/configcat/js-sdk/actions/workflows/js-ci.yml) \n[![codecov](https://codecov.io/gh/configcat/js-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/configcat/js-sdk) \n[![Known Vulnerabilities](https://snyk.io/test/github/configcat/js-sdk/badge.svg?targetFile=package.json)](https://snyk.io/test/github/configcat/js-sdk?targetFile=package.json) \n[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=configcat_js-sdk\u0026metric=reliability_rating)](https://sonarcloud.io/dashboard?id=configcat_js-sdk) \n[![Tree Shaking](https://badgen.net/bundlephobia/tree-shaking/configcat-js)](https://bundlephobia.com/result?p=configcat-js) \n![License](https://img.shields.io/github/license/configcat/js-sdk.svg) \n[![](https://data.jsdelivr.com/v1/package/npm/configcat-js/badge)](https://www.jsdelivr.com/package/npm/configcat-js)\n[![NPM](https://nodei.co/npm/configcat-js.png)](https://nodei.co/npm/configcat-js/)\n\n## Getting Started\n\n### 1. Install and import package:\n\n*via NPM [package](https://npmjs.com/package/configcat-js):*\n```PowerShell\nnpm i configcat-js\n```\n```js\nimport * as configcat from \"configcat-js\";\n```\n\n*via CDN:*\n```html\n\u003cscript type=\"text/javascript\" src=\"https://cdn.jsdelivr.net/npm/configcat-js@latest/dist/configcat.min.js\"\u003e\u003c/script\u003e\n```\n\n### 2. Go to the \u003ca href=\"https://app.configcat.com/sdkkey\" target=\"_blank\"\u003eConfigCat Dashboard\u003c/a\u003e to get your *SDK Key*:\n![SDK-KEY](https://raw.githubusercontent.com/ConfigCat/js-sdk/master/media/readme02-3.png  \"SDK-KEY\")\n\n### 3. Create a *ConfigCat* client instance:\n```js\nconst configCatClient = configcat.getClient(\"#YOUR-SDK-KEY#\");\n```\n\n\u003e You can acquire singleton client instances for your SDK keys using the `getClient(\"\u003csdkKey\u003e\")` factory function.\n(However, please keep in mind that subsequent calls to `getClient()` with the *same SDK Key* return a *shared* client instance, which was set up by the first call.)\n\n### 4. Get your setting value:\nThe async/await way:\n```js\nconst value = await configCatClient.getValueAsync('isMyAwesomeFeatureEnabled', false);\n\nif (value) {\n  do_the_new_thing();\n} else {\n  do_the_old_thing();\n}\n```\nor the Promise way:\n```js\nconfigCatClient.getValueAsync('isMyAwesomeFeatureEnabled', false)\n  .then((value) =\u003e {\n    if (value) {\n      do_the_new_thing();\n    } else {\n      do_the_old_thing();\n    }\n  });\n```\n\n## Getting user specific setting values with Targeting\nUsing this feature, you will be able to get different setting values for different users in your application by passing a `User Object` to `getValue()` or `getValueAsync()`.\n\nRead more about [Targeting here](https://configcat.com/docs/advanced/targeting/).\n```js\nconst userObject = new configcat.User(\"#USER-IDENTIFIER#\");\nconst value = await configCatClient.getValueAsync('isMyAwesomeFeatureEnabled', false, userObject);\n\nif (value) {\n  do_the_new_thing();\n} else {\n  do_the_old_thing();\n}\n```\n\n## Sample/Demo apps\n  - [Angular 2+](https://github.com/configcat/js-sdk/tree/master/samples/angular-sample)\n  - [React](https://github.com/configcat/js-sdk/tree/master/samples/react-sample)\n  - [Pure HTML + JS](https://github.com/configcat/js-sdk/tree/master/samples/html)\n\n## Polling Modes\nThe ConfigCat SDK supports 3 different polling mechanisms to acquire the setting values from ConfigCat. After latest setting values are downloaded, they are stored in the internal cache then all requests are served from there. Read more about Polling Modes and how to use them at [ConfigCat Docs](https://configcat.com/docs/sdk-reference/js/).\n\n## Sensitive information handling\n\nThe frontend/mobile SDKs are running in your users' browsers/devices. The SDK is downloading a [config.json](https://configcat.com/docs/requests/) file from ConfigCat's CDN servers. The URL path for this config.json file contains your SDK key, so the SDK key and the content of your config.json file (feature flag keys, feature flag values, targeting rules, % rules) can be visible to your users. \nThis SDK key is read-only, it only allows downloading your config.json file, but nobody can make any changes with it in your ConfigCat account.  \nSuppose you don't want your SDK key or the content of your config.json file visible to your users. In that case, we recommend you use the SDK only in your backend applications and call a backend endpoint in your frontend/mobile application to evaluate the feature flags for a specific application customer.  \nAlso, we recommend using [sensitive targeting comparators](https://configcat.com/docs/advanced/targeting/#sensitive-text-comparators) in the targeting rules of those feature flags that are used in the frontend/mobile SDKs.\n\n## Browser compatibility\nThis SDK should be compatible with all modern browsers.\n\nThe SDK is [tested](https://github.com/configcat/js-sdk/blob/master/.github/workflows/js-ci.yml) against the following browsers:\n- Chrome (stable, latest, beta)\n- Chromium (64.0.3282.0, 72.0.3626.0, 80.0.3987.0)\n- Firefox (latest, latest-beta, 84.0).\n\nThese tests are running on each pull request, before each deploy, and on a daily basis. \nYou can view a sample run [here](https://github.com/configcat/js-sdk/actions/runs/2420592907).\n\n## Need help?\nhttps://configcat.com/support\n\n## Contributing\nContributions are welcome. For more info please read the [Contribution Guideline](CONTRIBUTING.md).\n\n## About ConfigCat\n- [Official ConfigCat SDK's for other platforms](https://github.com/configcat)\n- [Documentation](https://configcat.com/docs)\n- [Blog](https://blog.configcat.com)\n\n## Troubleshooting\n\n`XMLHttpRequest module not defined/found`:\n\nSince the `configcat-js` SDK needs to download the feature flag and setting values from ConfigCat's servers via a HTTP GET request. The SDK uses `XMLHttpRequest` a built in object in all browsers. This way the package size is smaller instead of using a 3rd party library. The error above can appear in cases when the `configcat-js` SDK is used within a SSR (Server-Side Rendering) Universal application. In these cases we recommend using [configcat-js-ssr](https://github.com/configcat/js-ssr-sdk) or [configcat-node](https://github.com/configcat/node-sdk).\n","funding_links":[],"categories":["Architecture and Advanced Topics"],"sub_categories":["Feature Flags"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconfigcat%2Fjs-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconfigcat%2Fjs-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconfigcat%2Fjs-sdk/lists"}