{"record":{"id":"99437d227f125970","repo":"FuelLabs/fuels-ts","slug":"provider-not-found","errorCode":null,"errorMessage":"Provider not found","messagePattern":"Provider not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/create-fuels-counter-guide/src/hooks/useBaseAssetId.tsx","lineNumber":10,"sourceCode":"import { useNamedQuery, useProvider } from \"@fuels/react\";\n\nexport const useBaseAssetId = () => {\n  const { provider } = useProvider();\n\n  return useNamedQuery(\"baseAssetId\", {\n    queryKey: [\"baseAssetId\"],\n    queryFn: async () => {\n      if (!provider) {\n        throw new Error(\"Provider not found\");\n      }\n\n      return await provider.getBaseAssetId();\n    },\n    placeholderData: undefined,\n  });\n};\n","sourceCodeStart":1,"sourceCodeEnd":18,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/apps/create-fuels-counter-guide/src/hooks/useBaseAssetId.tsx#L1-L18","documentation":"Thrown by the useBaseAssetId React hook (create-fuels-counter-guide app) inside its react-query queryFn when useProvider() returns a falsy provider. The hook cannot call provider.getBaseAssetId() without a connected Provider, so it throws a plain Error (not a FuelError). This is a guard for missing wallet/network context in the React tree.","triggerScenarios":"Rendering a component that calls useBaseAssetId() without a <FuelProvider> (or equivalent) ancestor providing a Provider via @fuels/react context. The queryFn runs, sees provider is undefined/null, and throws 'Provider not found'.","commonSituations":"Forgetting to wrap the app in the Fuel provider component. Provider still initializing/connecting when the query first runs. Wrong import or context boundary. Using the hook outside the FuelReact context after a refactor.","solutions":["Wrap the component tree (or the screen using useBaseAssetId) in the Fuel provider so useProvider() returns a connected Provider.","Ensure the provider has finished connecting before rendering consumers (gate on its connection status).","Only call useBaseAssetId within components mounted under the provider.","Provide a fallback UI while the provider is unavailable."],"exampleFix":"// before\nfunction App() {\n  return <Counter />; // useBaseAssetId throws\n}\n\n// after\nimport { FuelProvider } from '@fuels/react';\nfunction App() {\n  return (\n    <FuelProvider>\n      <Counter />\n    </FuelProvider>\n  );\n}","handlingStrategy":"try-catch","validationCode":"import { useProvider } from '@fuels/react';\n// before calling useBaseAssetId, ensure a provider exists:\nconst { provider } = useProvider();\nif (!provider) throw new Error('Mount this component under <FuelProvider>');","typeGuard":"const hasProvider = (ctx: ReturnType<typeof useProvider>): boolean =>\n  ctx.provider != null;","tryCatchPattern":"// In a consuming component:\nconst q = useBaseAssetId();\n// react-query surfaces 'Provider not found' as q.error; render a fallback:\nif (q.error) return <p>Connect to a Fuel provider first.</p>;","preventionTips":["Always wrap the app tree with the Fuel provider component.","Gate provider-dependent hooks behind the provider's connection-ready state.","Only mount components using these hooks under the provider subtree."],"tags":["react","provider","context","usebaseassetid","create-fuels"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}