{"record":{"id":"228b3e0d77586044","repo":"FuelLabs/fuels-ts","slug":"provider-not-found-228b3e","errorCode":null,"errorMessage":"Provider not found","messagePattern":"Provider not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"templates/vite/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/templates/vite/src/hooks/useBaseAssetId.tsx#L1-L18","documentation":"Thrown by the useBaseAssetId React hook (vite template) inside its react-query queryFn when useProvider() returns no provider. Same guard as the other templates: the hook needs a connected Provider from the @fuels/react context to invoke provider.getBaseAssetId(); a missing provider makes the queryFn throw 'Provider not found'.","triggerScenarios":"Using useBaseAssetId() in a Vite React component that is rendered outside the Fuel provider context, so useProvider() returns undefined and the queryFn throws.","commonSituations":"main.tsx/App not wrapped with the Fuel provider. Provider still connecting on initial mount. Hook called in a route/component not under the provider subtree.","solutions":["Wrap the Vite app root with the Fuel provider so useProvider() returns a connected Provider.","Only mount components that use useBaseAssetId once the provider reports it is connected.","Verify the provider component is an ancestor in the React tree.","Show a loading/fallback state while the provider initializes."],"exampleFix":"// before\n// main.tsx\nReactDOM.createRoot(root).render(<App />); // no provider\n\n// after\nimport { FuelProvider } from '@fuels/react';\nReactDOM.createRoot(root).render(\n  <FuelProvider><App /></FuelProvider>\n);","handlingStrategy":"try-catch","validationCode":"import { useProvider } from '@fuels/react';\nconst { provider } = useProvider();\nif (!provider) throw new Error('Wrap the Vite root with <FuelProvider>');","typeGuard":"const hasProvider = (ctx: ReturnType<typeof useProvider>): boolean =>\n  ctx.provider != null;","tryCatchPattern":"const q = useBaseAssetId();\nif (q.isError) return <div>Provider not connected.</div>;","preventionTips":["Wrap the Vite root with the Fuel provider in main.tsx.","Render provider-dependent components only after the provider connects.","Confirm the provider sits above all hook consumers in the tree."],"tags":["react","vite","provider","context","usebaseassetid"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}