{"id":27904813,"url":"https://github.com/fontebasso/tiny-feature-flags","last_synced_at":"2025-05-05T23:33:30.049Z","repository":{"id":291339199,"uuid":"977285443","full_name":"fontebasso/tiny-feature-flags","owner":"fontebasso","description":"A tiny, dependency-free feature flag library designed for serverless, edge, and modern JavaScript runtimes. Built to be safe, deterministic, and easy to integrate anywhere.","archived":false,"fork":false,"pushed_at":"2025-05-04T01:10:39.000Z","size":168,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-04T01:19:31.404Z","etag":null,"topics":["deterministic","edge","feature-flags","rollout","sdk","typescript"],"latest_commit_sha":null,"homepage":"","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/fontebasso.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-03T21:01:56.000Z","updated_at":"2025-05-04T01:10:42.000Z","dependencies_parsed_at":"2025-05-04T01:29:35.655Z","dependency_job_id":null,"html_url":"https://github.com/fontebasso/tiny-feature-flags","commit_stats":null,"previous_names":["fontebasso/tiny-feature-flags"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fontebasso%2Ftiny-feature-flags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fontebasso%2Ftiny-feature-flags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fontebasso%2Ftiny-feature-flags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fontebasso%2Ftiny-feature-flags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fontebasso","download_url":"https://codeload.github.com/fontebasso/tiny-feature-flags/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252594233,"owners_count":21773629,"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":["deterministic","edge","feature-flags","rollout","sdk","typescript"],"created_at":"2025-05-05T23:33:29.477Z","updated_at":"2025-05-05T23:33:30.038Z","avatar_url":"https://github.com/fontebasso.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tiny-feature-flags\n\n[![tests](https://github.com/fontebasso/tiny-feature-flags/actions/workflows/tests.yml/badge.svg)](https://github.com/fontebasso/tiny-feature-flags/actions/workflows/tests.yml)\n[![npm](https://img.shields.io/npm/v/tiny-feature-flags)](https://www.npmjs.com/package/tiny-feature-flags)\n[![npm audit signatures](https://img.shields.io/badge/npm%20audit-signed%20%26%20attested-brightgreen?logo=npm)](https://docs.npmjs.com/generating-provenance-statements)\n[![license](https://img.shields.io/npm/l/tiny-feature-flags)](LICENSE)\n\nA tiny, dependency-free feature flag library designed for serverless, edge, and modern JavaScript runtimes. Built to be safe, deterministic, and easy to integrate anywhere.\n\n## Use cases\n\n- Gradual feature rollout using `rollout`\n- A/B testing by user traits (plan, region, etc.)\n- Environment-based toggles without external services\n- Fast evaluation in edge or serverless environments\n\n## Why tiny-feature-flags\n\n- Zero dependencies\n- Works in Node.js, Edge Functions, Vercel, Cloudflare Workers\n- Runtime evaluation with user traits and percentage rollout\n- Designed to be deterministic and side-effect-free\n- Fully tested with 100% code coverage\n\n## Installation\n\n```bash\nnpm install tiny-feature-flags\n```\n\n## Quick start\n\n```ts\nimport { TinyFlags } from 'tiny-feature-flags'\n\nconst flags = await TinyFlags.load('https://example.com/flags.json', {\n  userId: 'user-123',\n  traits: { region: 'us', plan: 'pro' },\n})\n\nif (flags.enabled('newSidebar')) {\n  showNewSidebar()\n}\n```\n\n### Sample JSON\n\n```json\n{\n  \"newSidebar\": { \"enabled\": true, \"rollout\": 30 },\n  \"v3Checkout\": { \"enabled\": true }\n}\n```\n\n## Evaluation logic\n\nEach flag has:\n\n- `enabled: boolean` — the base toggle\n- Optional `rollout: number` — deterministic activation based on user ID hash\n\nUnknown flags always return `false`.\n\n## API reference\n\n```ts\nclass TinyFlags {\n  constructor(flags: FlagSet, context?: FlagContext)\n  static async load(url: string, context?: FlagContext): Promise\u003cTinyFlags\u003e\n  enabled(flagName: string): boolean\n}\n```\n\n### Types\n\n```ts\ntype FlagContext = {\n  userId?: string\n  traits?: Record\u003cstring, string\u003e\n}\n\ntype FlagDefinition = {\n  enabled: boolean\n  rollout?: number\n}\n\ntype FlagSet = Record\u003cstring, FlagDefinition\u003e\n```\n\n## Hosting your flags\n\nServe JSON from any HTTPS endpoint. It can be hosted on:\n\n- GitHub Gist\n- Amazon S3\n- Your own static server\n- CDN with edge caching\n\n## Example: usage with Vercel Edge Function\n\n```ts\nexport const runtime = 'edge'\n\nimport { TinyFlags } from 'tiny-feature-flags'\nimport { NextRequest } from 'next/server'\n\nexport async function GET(req: NextRequest) {\n  const userId = req.cookies.get('user_id')?.value || 'anonymous'\n\n  const flags = await TinyFlags.load('https://example.com/flags.json', {\n    userId,\n    traits: { region: 'br', plan: 'pro' },\n  })\n\n  return Response.json({\n    showNewSidebar: flags.enabled('newSidebar'),\n  })\n}\n```\n\n## Tests and reliability\n\n- 100% test coverage using Vitest\n- Deterministic logic across all environments\n- Includes validation and error handling for unexpected responses\n\n## Design considerations\n\n- Default to `false` for unknown flags\n- Stateless by design\n- Safe for usage in edge and serverless runtimes\n\n## Contributing\n\nContributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## License\n\nThis library is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffontebasso%2Ftiny-feature-flags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffontebasso%2Ftiny-feature-flags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffontebasso%2Ftiny-feature-flags/lists"}