{"record":{"id":"b4395ac197ec9b5b","repo":"withastro/astro","slug":"nomatchingimport","errorCode":"NoMatchingImport","errorMessage":"Could not render `${componentName}`. No matching import has been found for `${componentName}`.","messagePattern":"Could not render `(.+?)`\\. No matching import has been found for `(.+?)`\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/runtime/server/hydration.ts","lineNumber":134,"sourceCode":"\ninterface HydrateScriptOptions {\n\trenderer: SSRLoadedRenderer;\n\tresult: SSRResult;\n\tastroId: string;\n\tprops: Record<string | number, any>;\n\tattrs: Record<string, string> | undefined;\n}\n\n/** For hydrated components, generate a <script type=\"module\"> to load the component */\nexport async function generateHydrateScript(\n\tscriptOptions: HydrateScriptOptions,\n\tmetadata: Required<AstroComponentMetadata>,\n): Promise<SSRElement> {\n\tconst { renderer, result, astroId, props, attrs } = scriptOptions;\n\tconst { hydrate, componentUrl, componentExport } = metadata;\n\n\tif (!componentExport.value) {\n\t\tthrow new AstroError({\n\t\t\t...AstroErrorData.NoMatchingImport,\n\t\t\tmessage: AstroErrorData.NoMatchingImport.message(metadata.displayName),\n\t\t});\n\t}\n\n\tconst island: SSRElement = {\n\t\tchildren: '',\n\t\tprops: {\n\t\t\t// This is for HMR, probably can avoid it in prod\n\t\t\tuid: astroId,\n\t\t},\n\t};\n\n\t// Attach renderer-provided attributes\n\tif (attrs) {\n\t\tfor (const [key, value] of Object.entries(attrs)) {\n\t\t\tisland.props[key] = escapeHTML(value);\n\t\t}","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/runtime/server/hydration.ts#L116-L152","documentation":"`generateHydrateScript` builds the `<script type=\"module\">` that hydrates an island. It needs `metadata.componentExport.value` (the resolved export name) to know what to import on the client. When that value is falsy, Astro never recorded a matching import/export for the component and cannot emit a working hydration script, so it throws `NoMatchingImport`.","triggerScenarios":"A component tagged with a `client:*` directive could not be statically resolved to a named/default export at build time (the import analysis found no usable export); the component reference is a dynamic/computed value Astro can't trace; the renderer's client entry didn't supply an export name.","commonSituations":"Trying to hydrate a component that is imported through an opaque wrapper, a function call, or a re-export Astro can't analyze; MDX components whose export Astro couldn't resolve; rendering a component from `astro:content` or a collection in a way that loses the export reference; missing/incorrect renderer client entry.","solutions":["Import the component with a static, analyzable import (`import Foo from './Foo'`) so Astro can record its export.","Remove the `client:*` directive if the component doesn't need hydration.","If the component comes from an integration/collection, render it through the documented API that preserves the export reference.","Re-run `astro sync` / rebuild so import metadata is regenerated."],"exampleFix":"// before — dynamic component reference Astro can't trace\nconst Comp = registry[name];\n<Comp client:load />   // NoMatchingImport\n\n// after — static import\nimport Counter from '../components/Counter.astro';\n<Counter client:load />","handlingStrategy":"validation","validationCode":"// Tooling-time: confirm a statically analyzable import exists for a hydrated component\nimport type { Component } from 'astro';\nfunction assertHydratable(Comp: unknown, name: string): void {\n  if (Comp == null) {\n    throw new Error(`Cannot hydrate '${name}': no resolvable import/export found`);\n  }\n}","typeGuard":"const isHydratableComponent = (v: unknown): boolean =>\n  typeof v === 'function' || (typeof v === 'object' && v !== null);","tryCatchPattern":null,"preventionTips":["Import hydrated components via static import statements.","Avoid dynamic/computed component references for `client:*` components.","Run `astro sync` after restructuring content/collection imports."],"tags":["hydration","import-analysis","component-exports","render"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}