{"record":{"id":"36d57d1a0a2d3d78","repo":"vercel/ai","slug":"invalid-value-this-hook-only-accepts-values-creat","errorCode":null,"errorMessage":"Invalid value: this hook only accepts values created via `createStreamableValue`.","messagePattern":"Invalid value: this hook only accepts values created via `createStreamableValue`\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/rsc/src/streamable-value/read-streamable-value.tsx","lineNumber":38,"sourceCode":" * }\n * ```\n *\n * And to read the value:\n *\n * ```js\n * const streamableValue = await action()\n * for await (const v of readStreamableValue(streamableValue)) {\n *   console.log(v)\n * }\n * ```\n *\n * This logs out 1, 2, 3 on console.\n */\nexport function readStreamableValue<T = unknown>(\n  streamableValue: StreamableValue<T>,\n): AsyncIterable<T | undefined> {\n  if (!isStreamableValue(streamableValue)) {\n    throw new Error(\n      'Invalid value: this hook only accepts values created via `createStreamableValue`.',\n    );\n  }\n\n  return {\n    [Symbol.asyncIterator]() {\n      let row: StreamableValue<T> | Promise<StreamableValue<T>> =\n        streamableValue;\n      let value = row.curr; // the current value\n      let isDone = false;\n      let isFirstIteration = true;\n\n      return {\n        async next() {\n          // the iteration is done already, return the last value:\n          if (isDone) return { value, done: true };\n\n          // resolve the promise at the beginning of each iteration:","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/rsc/src/streamable-value/read-streamable-value.tsx#L20-L56","documentation":"readStreamableValue only accepts objects produced by createStreamableValue; it detects the internal StreamableValue signature via isStreamableValue and throws otherwise. This prevents consuming arbitrary objects as streams and gives a clear message instead of confusing runtime failures later.","triggerScenarios":"Passing a plain object, a Promise, a string, or an object created by a different library version to readStreamableValue; passing a value from createStreamableUI (UI chunk) instead of createStreamableValue; reading a deserialized value that lost the internal signature.","commonSituations":"Mixing value streams with UI streams; TypeScript types erased or value JSON-serialized across a boundary, dropping the marker; version mismatch between the package that created the value and the one consuming it.","solutions":["Pass only values returned from createStreamableValue().value","Verify you are not passing a createStreamableUI result where a streamable value is expected","Check for AI SDK version mismatches between server code creating the value and client code reading it"],"exampleFix":"// before\nconst [value] = useState(42);\nreadStreamableValue(value); // throws\n// after\nconst streamable = createStreamableValue(42);\nreadStreamableValue(streamable.value);","handlingStrategy":"type-guard","validationCode":"import { isStreamableValue } from 'ai/rsc';\nif (!isStreamableValue(maybeValue)) throw new TypeError('expected createStreamableValue().value');","typeGuard":"function isStreamableValueLike(v: unknown): v is StreamableValue {\n  return typeof v === 'object' && v !== null && 'type' in v && 'curr' in v;\n}","tryCatchPattern":"try {\n  for await (const v of readStreamableValue(input)) { /* ... */ }\n} catch (e) {\n  if (e instanceof Error && e.message.includes('createStreamableValue')) {\n    console.error('Not a streamable value:', input);\n    return;\n  }\n  throw e;\n}","preventionTips":["Only pass values straight from createStreamableValue","Do not JSON round-trip StreamableValue objects","Match AI SDK versions between producer and consumer"],"tags":["streaming","invalid-argument","hooks"],"backgroundTag":"invalid-streamable-value","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}