{"record":{"id":"b33c7b2eb89a18ab","repo":"clockworklabs/SpacetimeDB","slug":"could-not-find-spacetimedb-client-did-you-forget-b33c7b","errorCode":null,"errorMessage":"Could not find SpacetimeDB client! Did you forget to add a `SpacetimeDBProvider`? `useTable` must be used in the SolidJS component tree under a `SpacetimeDBProvider` component.","messagePattern":"Could not find SpacetimeDB client! Did you forget to add a `SpacetimeDBProvider`\\? `useTable` must be used in the SolidJS component tree under a `SpacetimeDBProvider` component\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/bindings-typescript/src/solid/useTable.ts","lineNumber":76,"sourceCode":" * );\n * ```\n */\nexport function useTable<TableDef extends UntypedTableDef>(\n  query: () => Query<TableDef>,\n  callbacks?: UseTableCallbacks<Prettify<RowType<TableDef>>>\n): [readonly Prettify<RowType<TableDef>>[], () => boolean] {\n  type UseTableRowType = RowType<TableDef>;\n  const enabled = callbacks?.enabled ?? (() => true);\n  const q = createMemo(query);\n  const accessorName = createMemo(() => getQueryAccessorName(q()));\n  const whereExpr = createMemo(() => getQueryWhereClause(q()));\n  const querySql = createMemo(() => toSql(q()));\n\n  let connectionState: import('./connection_state').ConnectionState;\n  try {\n    connectionState = useSpacetimeDB();\n  } catch {\n    throw new Error(\n      'Could not find SpacetimeDB client! Did you forget to add a ' +\n        '`SpacetimeDBProvider`? `useTable` must be used in the SolidJS component tree ' +\n        'under a `SpacetimeDBProvider` component.'\n    );\n  }\n\n  const [rows, setRows] = createStore<readonly Prettify<UseTableRowType>[]>([]);\n\n  let latestTransactionEventId: string | null = null;\n\n  const computeSnapshot = (): readonly Prettify<UseTableRowType>[] => {\n    if (!enabled()) {\n      return [];\n    }\n\n    const connection = connectionState.getConnection();\n    if (!connection) {\n      return [];","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/bindings-typescript/src/solid/useTable.ts#L58-L94","documentation":"useTable in the Solid bindings calls useSpacetimeDB() inside a try/catch; when the context lookup fails because there is no SpacetimeDBProvider above, the original error is discarded and this dedicated message is thrown instead. The subscription machinery cannot even start because there is no connection to subscribe with, so the hook fails immediately at call time, before the enabled() gate is consulted.","triggerScenarios":"Calling useTable(tables.x) or useTable(query, { enabled }) from the Solid bindings inside a component that lacks a <SpacetimeDBProvider connectionBuilder={...}> ancestor. Even conditionally enabled queries throw, because the provider check runs before the enabled() check.","commonSituations":"Provider added to a subset of routes while a shared component uses useTable; tests rendering the table component in isolation; porting from React where the provider API differs; provider placed after (below) the consumer in the tree.","solutions":["Add <SpacetimeDBProvider connectionBuilder={builder}> above the component calling useTable","Confirm you used the Solid bindings' own provider, not the React or Vue one","In tests, render the component inside the provider before asserting rows","Check that the useTable import comes from the solid entry point and that the provider wraps the whole subtree"],"exampleFix":"// before\nexport default function App() {\n  const [players] = useTable(tables.player); // throws: no provider above\n  return <For each={players}>{(p) => <div>{p.name}</div>}</For>;\n}\n\n// after\nimport { SpacetimeDBProvider } from '@clockworklabs/spacetime-db-solid';\n\nexport default function App() {\n  return (\n    <SpacetimeDBProvider connectionBuilder={builder}>\n      <Players />\n    </SpacetimeDBProvider>\n  );\n}","handlingStrategy":"try-catch","validationCode":"import { useContext } from 'solid-js';\nimport { SpacetimeDBContext } from './solid/useSpacetimeDB';\n\n// gate hook usage on provider presence\nconst canUseTables = () => useContext(SpacetimeDBContext) !== undefined;","typeGuard":null,"tryCatchPattern":"// useTable throws during render; wrap consumers in Solid's ErrorBoundary\n<ErrorBoundary fallback={(err) => <div>{String(err)}</div>}>\n  <TableComponent />\n</ErrorBoundary>","preventionTips":["Always mount table components through a shared layout that contains the provider","Smoke-test each table component inside the provider in unit tests","Import provider and hooks from the same bindings package"],"tags":["solid","hooks","usetable","provider","typescript"],"backgroundTag":"missing-context-provider","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}