{"_id":"@avsbhq/solid","_rev":"5-3c1ab79979b36339bf5eb30bda36f9ba","name":"@avsbhq/solid","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"@avsbhq/solid","version":"1.0.0","_id":"@avsbhq/solid@1.0.0","maintainers":[{"name":"main1479","email":"m.main2402@gmail.com"}],"homepage":"https://github.com/main1479/a-vs-b/tree/main/packages/avsb-solid#readme","bugs":{"url":"https://github.com/main1479/a-vs-b/issues"},"dist":{"shasum":"8c4b9fa71a31f9d85bab1af08f99f92d6ab1edeb","tarball":"https://registry.npmjs.org/@avsbhq/solid/-/solid-1.0.0.tgz","fileCount":10,"integrity":"sha512-UE5QTBVjTzzJCzM0UZdWhR3tyat1zP7+JjXyJEhP7e/pvQ0AeeLXsA8Pn3X+nhFGdcVDAvoqQAv6sBeiP7bl3g==","signatures":[{"sig":"MEUCIQDfjjADmuWXctwunEvqFsXzyR4de4Z5Yvi4a4s+TbO9gwIgb0BLJdVaA5XUXWX6o8pZPknqEB4RsWgkmH5nOPYETGk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":57967},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"solid":"./dist/index.jsx","types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./solid-start":{"types":"./dist/solid-start.d.ts","import":"./dist/solid-start.js","require":"./dist/solid-start.cjs"}},"gitHead":"8cd6226e120fe67c198b2f1db0087cd38b4a4060","scripts":{"dev":"tsup --watch","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"main1479","email":"m.main2402@gmail.com"},"repository":{"url":"git+https://github.com/main1479/a-vs-b.git","type":"git","directory":"packages/avsb-solid"},"_npmVersion":"10.9.2","description":"Solid JS SDK for the [A vs B](https://app.avsb.cloud) platform.","directories":{},"_nodeVersion":"22.14.0","dependencies":{"@avsbhq/core":"1.0.0","@avsbhq/browser":"1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^2.0.0","solid-js":"^1.8.0","happy-dom":"^14.0.0","typescript":"^5.5.0","vite-plugin-solid":"^2.10.0"},"peerDependencies":{"solid-js":">=1.8.0"},"peerDependenciesMeta":{"@solidjs/start":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/solid_1.0.0_1780034369463_0.051173057500085495","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@avsbhq/solid","version":"1.0.1","_id":"@avsbhq/solid@1.0.1","maintainers":[{"name":"main1479","email":"m.main2402@gmail.com"}],"homepage":"https://github.com/main1479/a-vs-b/tree/main/packages/avsb-solid#readme","bugs":{"url":"https://github.com/main1479/a-vs-b/issues"},"dist":{"shasum":"d1dfaf35dd90db7750ee2a96b27b0161ccd7b5dc","tarball":"https://registry.npmjs.org/@avsbhq/solid/-/solid-1.0.1.tgz","fileCount":10,"integrity":"sha512-CI9XuJANMlxIv1nxrbrJObklMOG9NGe1Jb7ire3RG7sLXFedAhF4zPy9h6opzjUAbg3kI3rKt570vDrKN6ASFA==","signatures":[{"sig":"MEUCICgtrOIhZYgtvgrdslYmLyC6j5htzPPjpAvdyPw8ERDUAiEAqSxde4vFf9DWqQ7WcNiMF93+eNy1KK6gS0hwAYV66LQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":57899},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"solid":"./dist/index.jsx","types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./solid-start":{"types":"./dist/solid-start.d.ts","import":"./dist/solid-start.js","require":"./dist/solid-start.cjs"}},"scripts":{"dev":"tsup --watch","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"main1479","email":"m.main2402@gmail.com"},"repository":{"url":"git+https://github.com/main1479/a-vs-b.git","type":"git","directory":"packages/avsb-solid"},"_npmVersion":"10.9.8","description":"Solid JS SDK for the [A vs B](https://app.avsb.cloud) platform.","directories":{},"_nodeVersion":"22.22.3","dependencies":{"@avsbhq/core":"1.4.0","@avsbhq/browser":"1.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^2.0.0","solid-js":"^1.8.0","happy-dom":"^14.0.0","typescript":"^5.5.0","vite-plugin-solid":"^2.10.0"},"peerDependencies":{"solid-js":">=1.8.0"},"peerDependenciesMeta":{"@solidjs/start":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/solid_1.0.1_1785346480075_0.8728878859622566","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@avsbhq/solid","version":"1.0.2","_id":"@avsbhq/solid@1.0.2","maintainers":[{"name":"main1479","email":"m.main2402@gmail.com"}],"homepage":"https://github.com/main1479/a-vs-b/tree/main/packages/avsb-solid#readme","bugs":{"url":"https://github.com/main1479/a-vs-b/issues"},"dist":{"shasum":"bd60b658952ec180a63fd3c40027b098d82bc409","tarball":"https://registry.npmjs.org/@avsbhq/solid/-/solid-1.0.2.tgz","fileCount":10,"integrity":"sha512-b/8JW7pmhrHZvjs3eMPoPLU49X9/XRX4YFRKKRs4kq6xRUg12gB8qZrEiBbnYAA5R8X1QDxyA8WsA01UziOanA==","signatures":[{"sig":"MEYCIQDOzq1SMj9iuMdhqIVvuelW9NI5YVxt7VqifmMibCCS0AIhAI8OL9jyfbAyiJcHUp4Oa6seLszSn7pAwKCRHXywBhJX","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":57899},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"solid":"./dist/index.jsx","types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./solid-start":{"types":"./dist/solid-start.d.ts","import":"./dist/solid-start.js","require":"./dist/solid-start.cjs"}},"scripts":{"dev":"tsup --watch","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"main1479","email":"m.main2402@gmail.com"},"repository":{"url":"git+https://github.com/main1479/a-vs-b.git","type":"git","directory":"packages/avsb-solid"},"_npmVersion":"10.9.8","description":"Solid JS SDK for the [A vs B](https://app.avsb.cloud) platform.","directories":{},"_nodeVersion":"22.22.3","dependencies":{"@avsbhq/core":"1.4.0","@avsbhq/browser":"1.3.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^2.0.0","solid-js":"^1.8.0","happy-dom":"^14.0.0","typescript":"^5.5.0","vite-plugin-solid":"^2.10.0"},"peerDependencies":{"solid-js":">=1.8.0"},"peerDependenciesMeta":{"@solidjs/start":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/solid_1.0.2_1785347986546_0.0784232261351745","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@avsbhq/solid","version":"1.1.0","keywords":["avsb","feature-flags","ab-testing","experiments","solid","solidjs","solid-start","sdk"],"license":"MIT","_id":"@avsbhq/solid@1.1.0","maintainers":[{"name":"main1479","email":"m.main2402@gmail.com"}],"homepage":"https://github.com/avsbhq/a-vs-b/tree/main/packages/avsb-solid#readme","bugs":{"url":"https://github.com/avsbhq/a-vs-b/issues"},"dist":{"shasum":"2ddb67b481dce9ed562565d13cd334d2d74c4a82","tarball":"https://registry.npmjs.org/@avsbhq/solid/-/solid-1.1.0.tgz","fileCount":34,"integrity":"sha512-8MahIfGLsPTh/KIE1GoDhlD79I3oteNRQrUUEcaMnft8HbDobBqtn6RjDQjqEhDNVo0sAb75u9k/tABJkPan4g==","signatures":[{"sig":"MEQCICyNzxKNysVCdCvTYZIIUv2aZkMK15318YwSAKAvx2MzAiBL9TDDd3I3faxuJ5dtaCkrL1iqc9PhfI8keVAa01dK6g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":153390},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"solid":"./src/index.ts","import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./testing":{"solid":"./src/testing.tsx","import":{"types":"./dist/testing.d.ts","default":"./dist/testing.js"},"require":{"types":"./dist/testing.d.cts","default":"./dist/testing.cjs"}},"./solid-start":{"import":{"types":"./dist/solid-start.d.ts","default":"./dist/solid-start.js"},"require":{"types":"./dist/solid-start.d.cts","default":"./dist/solid-start.cjs"}},"./package.json":"./package.json"},"gitHead":"5eed46d5944b522ba0aa34e82850c98bb91667fe","scripts":{"dev":"tsup --watch","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"main1479","email":"m.main2402@gmail.com"},"repository":{"url":"git+https://github.com/avsbhq/a-vs-b.git","type":"git","directory":"packages/avsb-solid"},"_npmVersion":"10.9.8","description":"Solid SDK for A vs B feature flags and experiments: signals, a provider, SolidStart helpers, and test helpers.","directories":{},"sideEffects":false,"_nodeVersion":"22.22.3","dependencies":{"@avsbhq/core":"^1.4.0","@avsbhq/browser":"^1.3.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^4.1.4","solid-js":"^1.8.0","happy-dom":"^14.0.0","typescript":"^5.5.0","vite-plugin-solid":"^2.10.0"},"peerDependencies":{"solid-js":">=1.8.0","@solidjs/start":">=1.0.0"},"peerDependenciesMeta":{"@solidjs/start":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/solid_1.1.0_1785971486523_0.2584274288476369","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@avsbhq/solid","version":"1.1.1","description":"Solid SDK for A vs B feature flags and experiments: signals, a provider, SolidStart helpers, and test helpers.","keywords":["avsb","feature-flags","ab-testing","experiments","solid","solidjs","solid-start","sdk"],"license":"MIT","type":"module","sideEffects":false,"main":"dist/index.cjs","module":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"solid":"./src/index.ts","import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./solid-start":{"import":{"types":"./dist/solid-start.d.ts","default":"./dist/solid-start.js"},"require":{"types":"./dist/solid-start.d.cts","default":"./dist/solid-start.cjs"}},"./testing":{"solid":"./src/testing.tsx","import":{"types":"./dist/testing.d.ts","default":"./dist/testing.js"},"require":{"types":"./dist/testing.d.cts","default":"./dist/testing.cjs"}},"./package.json":"./package.json"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/avsbhq/a-vs-b.git","directory":"packages/avsb-solid"},"homepage":"https://github.com/avsbhq/a-vs-b/tree/main/packages/avsb-solid#readme","bugs":{"url":"https://github.com/avsbhq/a-vs-b/issues"},"scripts":{"build":"tsup","dev":"tsup --watch","test":"vitest run","typecheck":"tsc --noEmit"},"peerDependencies":{"@solidjs/start":">=1.0.0","solid-js":">=1.8.0"},"peerDependenciesMeta":{"@solidjs/start":{"optional":true}},"dependencies":{"@avsbhq/browser":"^1.3.1","@avsbhq/core":"^1.4.0"},"devDependencies":{"happy-dom":"^14.0.0","solid-js":"^1.8.0","tsup":"^8.0.0","typescript":"^5.5.0","vite-plugin-solid":"^2.10.0","vitest":"^4.1.4"},"_id":"@avsbhq/solid@1.1.1","gitHead":"d31d88fbf202f40041b4cb47f77882f454fa5ef8","_nodeVersion":"22.22.3","_npmVersion":"10.9.8","dist":{"integrity":"sha512-k1jiJsKYggKyajiJxpQJZF7ClEHXqVweJVyOG8LF/CyQ2PqcfJfsna3YEeIOwQ+iR2tCpz33GExe5cZKT703PA==","shasum":"4642db5985a4c8635c9eda0873a0e7c8fa350e3c","tarball":"https://registry.npmjs.org/@avsbhq/solid/-/solid-1.1.1.tgz","fileCount":34,"unpackedSize":153454,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDXoqqA/YZ+v8yu+5FZEYDx9Oy1EV883Orx370a/JfYXAiApYvK9h3jei8XQWTwyOc2FAjCxY1kSpFoMtv4hNpvL2g=="}]},"_npmUser":{"name":"main1479","email":"m.main2402@gmail.com"},"directories":{},"maintainers":[{"name":"main1479","email":"m.main2402@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/solid_1.1.1_1786795883003_0.9809766551664629"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-29T05:59:29.326Z","modified":"2026-08-15T12:11:23.316Z","1.0.0":"2026-05-29T05:59:29.619Z","1.0.1":"2026-07-29T17:34:40.223Z","1.0.2":"2026-07-29T17:59:46.688Z","1.1.0":"2026-08-05T23:11:26.683Z","1.1.1":"2026-08-15T12:11:23.129Z"},"bugs":{"url":"https://github.com/avsbhq/a-vs-b/issues"},"license":"MIT","homepage":"https://github.com/avsbhq/a-vs-b/tree/main/packages/avsb-solid#readme","keywords":["avsb","feature-flags","ab-testing","experiments","solid","solidjs","solid-start","sdk"],"repository":{"type":"git","url":"git+https://github.com/avsbhq/a-vs-b.git","directory":"packages/avsb-solid"},"description":"Solid SDK for A vs B feature flags and experiments: signals, a provider, SolidStart helpers, and test helpers.","maintainers":[{"name":"main1479","email":"m.main2402@gmail.com"}],"readme":"# @avsbhq/solid\n\nSolid SDK for the [A vs B](https://app.avsb.cloud) platform.\n\nMount one `<AvsbProvider>`, then read feature flags with accessors. Built on [`@avsbhq/browser`](https://www.npmjs.com/package/@avsbhq/browser): a component re-runs when the flag it reads changes, and only then.\n\n---\n\n## 1. Install\n\n```bash\nnpm install @avsbhq/solid\n```\n\nSolid 1.8 or later is required as a peer dependency. `@solidjs/start` is an optional peer: install it if you use the server helpers.\n\n---\n\n## 2. Quickstart\n\n```tsx\n// src/index.tsx\nimport { render } from 'solid-js/web';\nimport { AvsbProvider } from '@avsbhq/solid';\nimport App from './App';\n\ndeclare const userId: string;\n\nrender(\n  () => (\n    <AvsbProvider\n      sdkKey={import.meta.env['VITE_AVSB_SDK_KEY'] as string}\n      context={{ kind: 'user', key: userId, plan: 'pro' }}\n    >\n      <App />\n    </AvsbProvider>\n  ),\n  document.getElementById('root') as HTMLElement,\n);\n```\n\n```tsx\n// src/CheckoutButton.tsx\nimport { createBoolFlag, createExposure, useTrack } from '@avsbhq/solid';\nimport type { Accessor, JSX } from 'solid-js';\nimport type { Flag } from '@avsbhq/solid';\n\nexport default function CheckoutButton(): JSX.Element {\n  const checkout: Accessor<Flag<boolean>> = createBoolFlag('new-checkout-flow', false);\n  const track = useTrack();\n\n  // The visitor is about to see this decision, so record it once.\n  createExposure('new-checkout-flow');\n\n  return (\n    <button onClick={() => track('checkout_started', { value: 99 })}>\n      {checkout().value ? 'Start checkout (new)' : 'Buy now'}\n    </button>\n  );\n}\n```\n\nBoth provider props matter: without `context` the visitor gets a persisted anonymous id, which is fine for anonymous experiments but cannot target logged-in attributes.\n\n---\n\n## 3. SDK keys\n\nGet the SDK key for the environment you want from your project: **app.avsb.cloud**, then **Settings**, then **Environments**. The format is `sdk_<environment>_<id>`, for example `sdk_production_ttqm0eaj4vth1krcb2xn`.\n\nThere is one SDK key per environment, and \"SDK key\" is its only name. There is no separate client key and server key to choose between.\n\nYour SDK key is a public identifier, not a secret: it is safe to ship in browser and mobile bundles, it can only fetch that environment's flag configuration and send events, and it can never read or change anything in your dashboard.\n\n```\nVITE_AVSB_SDK_KEY=sdk_production_...\n```\n\nThe client checks the shape of the key when it is constructed. A key that does not look like an SDK key (a pasted dashboard URL, a truncated copy, a personal access token or a service token) logs one actionable error naming what it got and where the real key lives.\n\n---\n\n## 4. The whole type surface\n\nEvery export, with its real signature. `FlagKeyInput = string | Accessor<string>`, so any read can follow a reactive key.\n\nThe signatures name the package's own types, and Solid's `Context`. Both come from here:\n\n```ts\nimport type {\n  AvsbClientOptions,\n  AvsbContextValue,\n  AvsbProviderProps,\n  EvalContext,\n  FlagDatafile,\n  FlagKeyInput,\n  SolidAvsbClient,\n  TrackPayload,\n  UseAvsbStatusResult,\n} from '@avsbhq/solid';\nimport type { Context } from 'solid-js';\n```\n\n```tsx\n// Provider\nfunction AvsbProvider(props: AvsbProviderProps): JSX.Element;\n\n// Reading flags\nfunction createFlag<T>(flagKey: FlagKeyInput, defaultValue: T): Accessor<Flag<T>>;\nfunction createFlagValue<T>(flagKey: FlagKeyInput, defaultValue: T): Accessor<T>;\nfunction createBoolFlag(flagKey: FlagKeyInput, defaultValue: boolean): Accessor<Flag<boolean>>;\nfunction createStringFlag(flagKey: FlagKeyInput, defaultValue: string): Accessor<Flag<string>>;\nfunction createNumberFlag(flagKey: FlagKeyInput, defaultValue: number): Accessor<Flag<number>>;\nfunction createJsonFlag<T>(flagKey: FlagKeyInput, defaultValue: T): Accessor<Flag<T>>;\nfunction createAllFlags(): Accessor<Record<string, Flag>>;\n\n// Readiness and errors\nfunction createFlagReady(): Accessor<boolean>;\nfunction useAvsbStatus(): UseAvsbStatusResult;\n\n// Client, identity, events\nfunction useAvsbClient(): SolidAvsbClient;\nfunction useTrack(): (eventKey: string, payload?: TrackPayload) => void;\nfunction useIdentify(): (context: EvalContext) => void;\nfunction useAlias(): (previousContext: EvalContext, newContext: EvalContext) => void;\nfunction useReset(): () => void;\nfunction createExposure(flagKey: FlagKeyInput): void;\nfunction createFlagSubscription(flagKey: FlagKeyInput, callback: (flag: Flag) => void): void;\n\n// Context, for custom providers\nconst AvsbContext: Context<AvsbContextValue | symbol>;\nfunction useAvsbContext(): AvsbContextValue;\nfunction hasAvsbContext(): boolean;\n```\n\n**Naming rule:** `create*` registers something reactive (a signal, an effect, a subscription that is cleaned up with the owner). `use*` reads the provider context and hands back a plain function. That is why exposure is `createExposure` (it schedules work on mount) while tracking is `useTrack` (it just gives you a function).\n\n### Provider props\n\n```tsx\ntype AvsbProviderProps =\n  | (AvsbClientOptions & { children: JSX.Element; client?: never })\n  | { client: SolidAvsbClient; children: JSX.Element };\n```\n\n**Mode A** (an `sdkKey`, plus any other `AvsbClientOptions` such as `context` or `bootstrap`) means the provider builds the client and closes it on cleanup. **Mode B** (a `client`) means you own its lifetime and the provider never closes it. Passing neither throws while the component is created, with a message naming both fixes, rather than rendering a tree where every flag is silently the default.\n\n### `AvsbContextValue`\n\n```tsx\ninterface AvsbContextValue {\n  client: SolidAvsbClient;\n  status: Accessor<'loading' | 'ready' | 'error'>;\n  error: Accessor<Error | undefined>;\n  degraded: Accessor<boolean>;\n}\n```\n\n### `Flag<T>`, the return type of every read\n\n```tsx\ninterface Flag<T = unknown> {\n  /** The variation value, typed against the default you passed. */\n  readonly value: T;\n  /** Variation key, null when the default was served or the flag is unknown. */\n  readonly variationKey: string | null;\n  /** Why this value was produced. */\n  readonly source: EvaluationSource;\n  readonly ruleId: string | null;\n  readonly ruleType: RuleType | null;\n  /** Structured reasons for this decision. Never null; may be empty. */\n  readonly reasons: string[];\n  readonly evaluatedAt: number;\n  readonly durationMicros: number;\n  /** A real decision produced a truthy value. */\n  isEnabled(): boolean;\n  /** False for 'not_found' and for 'not_ready'. */\n  exists(): boolean;\n}\n\ntype RuleType = 'targeted_delivery' | 'ab_test' | 'holdout' | 'bandit';\n\ntype EvaluationSource =\n  | 'datafileOverride'\n  | 'runtimeOverride'\n  | 'sticky'\n  | 'rule'\n  | 'holdout'\n  | 'bandit'\n  | 'default'\n  | 'not_found'\n  | 'disabled'\n  | 'not_ready';\n```\n\n| `source`           | Meaning                                                       | `isEnabled()`   | `exists()` |\n| ------------------ | ------------------------------------------------------------- | --------------- | ---------- |\n| `datafileOverride` | A per-user override in the dashboard matched.                 | value-dependent | true       |\n| `runtimeOverride`  | `setOverrideForUser` or `setGlobalOverride` matched.          | value-dependent | true       |\n| `sticky`           | A previously stored assignment was reused.                    | value-dependent | true       |\n| `rule`             | A targeting rule or A/B rule matched.                         | value-dependent | true       |\n| `holdout`          | The visitor is held out, so the holdout variation was served. | value-dependent | true       |\n| `bandit`           | A bandit rule picked the variation.                           | value-dependent | true       |\n| `default`          | The flag exists, nothing matched, default variation served.   | false           | true       |\n| `disabled`         | The flag exists but is off in this environment.               | false           | true       |\n| `not_found`        | The datafile loaded and has no such key. Check the name.      | false           | false      |\n| `not_ready`        | No datafile yet. Gate on `createFlagReady()`.                 | false           | false      |\n\n\"value-dependent\" means `isEnabled()` is `Boolean(flag.value)`.\n\n### `UseAvsbStatusResult`\n\n```tsx\ninterface UseAvsbStatusResult {\n  status: Accessor<'loading' | 'ready' | 'error'>;\n  error: Accessor<Error | undefined>;\n  degraded: Accessor<boolean>;\n}\n```\n\n### Typed flag keys\n\n`FlagKeyInput` is built from `string` until you generate your keys. Generate\nthem and it is built from the union of this project's real flag keys, so a typo\nis a compile error and your editor completes the list:\n\n```bash\nnpx avsb codegen --output src/generated/flags.ts\n```\n\nThe generated file declares your flags twice on purpose: an importable\n`FlagValues` interface for payload types, and a `declare global` block that\nteaches every accessor in this package which keys exist. Its important parts:\n\n```text\n// AUTO-GENERATED by @avsbhq/cli codegen. Do not edit by hand.\n\nexport interface FlagValues {\n  'checkout-v2': boolean\n  'hero-copy': 'control' | 'variant-a'\n  'theme': { primary: string }\n}\n\ndeclare global {\n  interface AvsbFlags {\n    'checkout-v2': boolean\n    'hero-copy': 'control' | 'variant-a'\n    'theme': { primary: string }\n  }\n}\n```\n\n```ts\nimport { createBoolFlag, createJsonFlag } from '@avsbhq/solid';\nimport type { FlagValues } from './generated/flags';\n\nconst checkout = createBoolFlag('checkout-v2', false);\n\n// A JSON flag types its payload from the generated table:\nconst theme = createJsonFlag<FlagValues['theme']>('theme', { primary: '#111' });\n\n// Once the generated file exists, this line stops compiling:\n// 'chekcout-v2' is not a flag key.\nconst typo = createBoolFlag('chekcout-v2', false);\n```\n\nOne real consequence for reactive keys: an `Accessor<string>` no longer\nsatisfies `FlagKeyInput` once your keys are generated, because that accessor\ncould return any string. Declare it as `Accessor<AvsbFlagKey>` and it fits\nagain.\n\nNothing changes for a project that never runs `codegen`: with no generated file\nthe table is empty, so `FlagKeyInput` accepts any string exactly as it does\ntoday, and every call you have already written compiles unchanged. For a key\ncomputed at runtime, widen deliberately with `key as AvsbFlagKey` (that type is\nexported from `@avsbhq/core`).\n\n---\n\n## 5. Reading flags\n\n```tsx\nimport { createBoolFlag, createJsonFlag, createFlagValue } from '@avsbhq/solid';\n\ninterface ApiConfig {\n  timeout: number;\n  retries: number;\n}\n\nconst darkMode = createBoolFlag('dark-mode', false);\nconst config = createJsonFlag<ApiConfig>('api-config', { timeout: 5000, retries: 3 });\nconst banner = createFlagValue('promo-banner', 'grey');\n\nconst timeout: number = config().value.timeout;\n```\n\nThe typed reads check the value against the type the platform declared for that flag. **On a mismatch nothing throws**: the SDK logs one warning naming the flag and the getter, then returns your `defaultValue` with `source: 'not_found'`. `createJsonFlag<T>` does not validate the shape of `T` at runtime, only that the flag is declared as JSON; validate the payload yourself if it crosses a trust boundary.\n\nA default value is always required, and it is what you get before the SDK is ready or when the key is unknown.\n\n### Reactive keys\n\n```tsx\nimport { createSignal } from 'solid-js';\n\nconst [selected, setSelected] = createSignal('feature-a');\nconst flag = createFlag(selected, false); // re-subscribes when `selected` changes\n```\n\n### Every flag at once\n\n```tsx\nconst flags = createAllFlags(); // Accessor<Record<string, Flag>>\n```\n\nRe-runs on any flag change, so prefer a single-flag accessor in normal components. Exposures are suppressed and the SDK returns the same object between changes, so this is cheap to read in JSX.\n\n---\n\n## 6. Identity\n\n```tsx\nimport { useAvsbClient, useIdentify, useAlias, useReset } from '@avsbhq/solid';\n\nconst client = useAvsbClient();\nconst identify = useIdentify();\nconst alias = useAlias();\nconst reset = useReset();\n\nfunction onSignIn(user: { id: string; email: string; plan: string }): void {\n  const context = client.getContext();\n  const anonymousKey: string = 'key' in context ? String(context['key']) : '';\n\n  // Same person, two sessions: this is what lets results stitch them.\n  alias({ kind: 'user', key: anonymousKey }, { kind: 'user', key: user.id });\n\n  identify({ kind: 'user', key: user.id, email: user.email, plan: user.plan });\n}\n```\n\nAnonymous visitors get a persisted id (localStorage, with a cookie fallback), so a returning visitor buckets into the same variation instead of being re-randomised on every load. If the A vs B web snippet is on the same page, the SDK adopts its visitor id so flag exposures and web experiment exposures join to one visitor.\n\n`alias` is synchronous: it queues one event and returns. There is nothing to await, and it does not rewrite assignments already made. `reset()` rotates to a new anonymous identity and clears runtime overrides; call it on sign-out.\n\n### Multi-context\n\n```tsx\nidentify({\n  kind: 'multi',\n  user: { kind: 'user', key: 'u_123', plan: 'pro' },\n  organization: { kind: 'organization', key: 'org_456', tier: 'enterprise' },\n});\n```\n\nA rule can bucket on `user.key` while matching an audience condition on `organization.tier`.\n\n---\n\n## 7. Exposures: what lands in your results\n\nReads never record an exposure. That is deliberate: an exposure means \"this visitor saw this decision\", and a component can re-run for reasons that have nothing to do with the visitor.\n\n```tsx\nimport { createExposure } from '@avsbhq/solid';\n\n// In the component that actually shows the variation:\ncreateExposure('new-checkout-flow');\n```\n\n`createExposure` fires on mount, once, or as soon as the SDK becomes ready if it is not yet. It is also what makes a server-rendered variant visible in results: if the value arrived as a prop from the server, call `createExposure` where it is rendered.\n\nOnly decisions that belong in an experiment (A/B rules, holdouts, bandits) produce an exposure event; a plain rollout has nothing to record.\n\nFor side effects that are not rendering:\n\n```tsx\ncreateFlagSubscription('new-checkout-flow', (flag) => {\n  analytics.track('checkout_variant_assigned', { variationKey: flag.variationKey });\n});\n```\n\n---\n\n## 8. Readiness and failure\n\n```tsx\nimport { useAvsbStatus } from '@avsbhq/solid';\nimport { Show } from 'solid-js';\n\nfunction Gate(): JSX.Element {\n  const { status, error, degraded } = useAvsbStatus();\n\n  return (\n    <Show when={status() !== 'loading'} fallback={<Skeleton />}>\n      <Show when={degraded()}>\n        <StaleDataNotice message={error()?.message} />\n      </Show>\n      <App />\n    </Show>\n  );\n}\n```\n\n- `'loading'`: no datafile yet and nothing cached.\n- `'ready'`: flags answer. A **degraded** client is ready: a refresh failed while a cached datafile is being served, so values work and may be stale. `error()` says why.\n- `'error'`: nothing could be loaded. Every flag returns the default you passed, and `error()?.message` names the HTTP status, the URL tried, and the fix.\n\nThe SDK's default logger writes to the console at `warn` level in development and is silent in production. Pass `logLevel=\"silent\"` (or any other `AvsbClientOptions` field) to the provider to change that.\n\n---\n\n## 9. SolidStart\n\n```tsx\n// src/middleware.ts\nimport { createMiddleware } from '@solidjs/start/middleware';\nimport { AvsbServer } from '@avsbhq/node';\nimport { withAvsbServerContext } from '@avsbhq/solid/solid-start';\n\nconst avsb = new AvsbServer({ sdkKey: process.env['AVSB_SDK_KEY'] ?? '' });\n\nexport default createMiddleware({\n  onRequest: [\n    withAvsbServerContext(() => {}, {\n      serverClient: avsb,\n      resolveContext: (event) => ({\n        kind: 'user',\n        key: event.request.headers.get('x-user-id') ?? 'anonymous',\n      }),\n    }),\n  ],\n});\n```\n\nThe inner handler returns nothing, on purpose. On the runner underneath SolidStart, an `onRequest` handler that returns a value is taken as the response for that request, so returning the event would short-circuit the route it was meant to pass through. Return a `Response` only when you mean to answer the request yourself.\n\n```tsx\nimport type {\n  AvsbBoundClient,\n  AvsbServerContextOptions,\n  SolidStartEvent,\n} from '@avsbhq/solid/solid-start';\n\ninterface AvsbServerLocals {\n  avsbContext: EvalContext | null;\n  avsbClient: AvsbBoundClient | null;\n  avsbBootstrap: FlagDatafile | null;\n}\n\ninterface AvsbServerClient {\n  forUser(context: EvalContext): AvsbBoundClient;\n  getDatafile(): FlagDatafile | null;\n}\n\n/** Pass the request through (return nothing) or answer it (return a Response). */\ntype SolidStartHandler = (event: SolidStartEvent) => void | Response | Promise<void | Response>;\n\nfunction withAvsbServerContext(\n  handler: SolidStartHandler,\n  options: AvsbServerContextOptions,\n): SolidStartHandler;\nfunction getAvsbBootstrap(serverClient: AvsbServerClient): FlagDatafile | null;\n```\n\n`AvsbServer` from `@avsbhq/node` satisfies `AvsbServerClient`, and the client its `forUser(context)` returns satisfies `AvsbBoundClient`, so nothing needs casting.\n\nRead flags on the server from `event.locals.avsbClient`, and pass `event.locals.avsbBootstrap` into the page so the client provider starts ready:\n\n```tsx\ndeclare const PUBLIC_SDK_KEY: string;\ndeclare const bootstrapFromServer: FlagDatafile;\n\nfunction Root(): JSX.Element {\n  return (\n    <AvsbProvider sdkKey={PUBLIC_SDK_KEY} bootstrap={bootstrapFromServer}>\n      <App />\n    </AvsbProvider>\n  );\n}\n```\n\n**What changed and why**: the previous helper took an `sdkKey` it never used, set `locals.avsbBootstrap = null` with a comment saying something else would fill it in (nothing did), and its `serializeAvsbBootstrap` cast a map of evaluated flags to `FlagDatafile`, which crashed the browser client at construction. `avsbBootstrap` is now the datafile, which is JSON-safe by construction because it is the document the CDN serves. Handing the browser server-evaluated VALUES instead is a different handoff that the browser SDK does not expose publicly yet.\n\n---\n\n## 10. Packaging\n\nThe `solid` export condition points at TypeScript source (`./src/index.ts`), which is what Solid libraries are supposed to ship: `vite-plugin-solid` compiles the JSX with your app's own settings, so there is one reactive runtime and one JSX transform. The bundled `dist` output is the fallback for toolchains that do not understand the condition.\n\nThe package used to declare `\"solid\": \"./dist/index.jsx\"`, a file the build never emitted, so every toolchain that honoured the condition got a missing file and everything else got esbuild-compiled JSX, which is exactly the setup Solid libraries are told to avoid.\n\n---\n\n## 11. One provider, please\n\nNesting a second `<AvsbProvider>` inside another shadows the outer one for everything below it: two clients, two visitor ids, two event queues, and identify calls that only reach one of them. The provider logs a warning in development when it detects this. Mount one provider at the root unless you deliberately want an isolated subtree.\n\n---\n\n## 12. Graceful shutdown\n\nMode A closes the client when the provider's owner is disposed, which flushes queued events. In Mode B you own it:\n\n```tsx\nimport { onCleanup } from 'solid-js';\n\nonCleanup(() => {\n  void client.close(); // flushes internally\n});\n```\n\n---\n\n## 13. Testing\n\n```tsx\nimport { render } from '@solidjs/testing-library';\nimport { AvsbTestProvider } from '@avsbhq/solid/testing';\n\nrender(() => (\n  <AvsbTestProvider flags={{ 'checkout-v2': true }}>\n    <CheckoutButton />\n  </AvsbTestProvider>\n));\n```\n\n`AvsbTestProvider` is the real `<AvsbProvider>` in Mode B around a real `AvsbClient` whose datafile is built from your flags map, with the network, the cache, and logging switched off. Components under test use the same accessors, the same evaluator, and the same exposure rules they use in production.\n\nDrive the client directly when that is simpler:\n\n```tsx\nimport { createTestClient, createTestDatafile } from '@avsbhq/solid/testing';\n\nconst client = createTestClient({ flags: { 'checkout-v2': true } });\nexpect(client.getBoolFlag('checkout-v2', false).isEnabled()).toBe(true);\n\n// Publish a new datafile and watch subscribers wake up.\nclient.applyDatafileBootstrap(\n  createTestDatafile({ 'checkout-v2': false }, { publishedAt: '2024-06-01T00:00:00.000Z' }),\n);\n```\n\n```tsx\nimport type { AvsbClient } from '@avsbhq/browser';\n\n/** Flag key to the value it serves. */\ntype TestFlags = Record<string, boolean | string | number | object | null>;\n\ninterface TestClientOptions {\n  flags?: TestFlags;\n  context?: EvalContext;\n  /** A full datafile, for when a map of values is not expressive enough. */\n  datafile?: FlagDatafile;\n}\n\nfunction createTestClient(options?: TestClientOptions): AvsbClient;\nfunction createTestDatafile(flags?: TestFlags, options?: { publishedAt?: string }): FlagDatafile;\n\ninterface AvsbTestProviderProps {\n  flags?: TestFlags;\n  context?: EvalContext;\n  client?: SolidAvsbClient;\n  children: JSX.Element;\n}\n```\n\nEach entry in `flags` becomes a fully rolled out flag, so `isEnabled()` is true for truthy values and reads record exposures exactly as an A/B rule would. Call `client.close()` at the end of a test that tracked events, so the flush timer does not outlive it.\n\n---\n\n## 14. Migration from LaunchDarkly\n\n| LaunchDarkly JS                      | `@avsbhq/solid`                                    |\n| ------------------------------------ | -------------------------------------------------- |\n| `initialize(clientId, context)`      | `<AvsbProvider sdkKey context>`                    |\n| `client.waitForInitialization()`     | `createFlagReady()` or `useAvsbStatus()`           |\n| `client.allFlags()`                  | `createAllFlags()`                                 |\n| `client.variation('key', false)`     | `createBoolFlag('key', false)().value`             |\n| `client.variationDetail('key', d)`   | `createFlag('key', d)()`                           |\n| `client.identify(context)`           | `useIdentify()(context)`                           |\n| `client.track('event', data, value)` | `useTrack()('event', { value, properties: data })` |\n| `client.on('change:key', cb)`        | `createFlagSubscription('key', cb)`                |\n\nDifferences worth knowing:\n\n- Every read returns a `Flag<T>` object, not a raw value, so you get the decision metadata without a second call.\n- Every read requires an explicit default. There is no untyped variation call.\n- Multi-context is first class: one `EvalContext` with kinds, no wrapper type.\n- Reads record no exposure. Call `createExposure(key)` where the visitor actually sees the decision.\n\n---\n\n## 15. Set this up with your AI assistant\n\nPaste this into Claude Code, Cursor, or any coding assistant:\n\n```text\nSet up A vs B feature flags in this Solid project.\n\n1. Run: npx @avsbhq/cli init\n   Use my saved CLI login: do not ask me for a token and do not put one in any file.\n   It detects Solid, writes the SDK key into the environment file this project's\n   bundler reads (VITE_AVSB_SDK_KEY for Vite), and writes an example component.\n2. Install @avsbhq/solid with this project's package manager.\n3. Mount <AvsbProvider> once at the root with that key and a context of\n   { kind: 'user', key: <your user id> }, then read the flag the example names.\n4. Reads are accessors over a Flag object, so call flag().value or\n   flag().isEnabled(), and always pass a fallback. Reading a flag records nothing:\n   call createExposure(key) where the variation is shown.\n5. Then run: npx @avsbhq/cli codegen\n\nDone looks like: the app starts, the flag reads without throwing, and avsb init\nprints the line confirming it saw the first check-in.\n```\n\n`avsb init` ends by waiting for your app's first check-in and printing what it\nsaw, so the terminal tells you it works rather than the dashboard.\n","readmeFilename":"README.md"}