{"record":{"id":"bb051dba5dd673c7","repo":"withastro/astro","slug":"astrojs-preact-importing-getcontainerrenderer","errorCode":null,"errorMessage":"[@astrojs/preact] Importing `getContainerRenderer` from `@astrojs/preact` is deprecated. Import it from `@astrojs/preact/container-renderer` instead.","messagePattern":"\\[@astrojs/preact\\] Importing `getContainerRenderer` from `@astrojs/preact` is deprecated\\. Import it from `@astrojs/preact/container-renderer` instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/integrations/preact/src/index.ts","lineNumber":18,"sourceCode":"import { fileURLToPath } from 'node:url';\nimport { preact, type PreactPluginOptions as VitePreactPluginOptions } from '@preact/preset-vite';\nimport type { AstroIntegration, AstroRenderer, ViteUserConfig } from 'astro';\nimport * as devalue from 'devalue';\nimport type { EnvironmentOptions, Plugin } from 'vite';\nimport {\n\tgetContainerRenderer as getContainerRendererImpl,\n\tgetRenderer,\n} from './container-renderer.js';\nimport type { VirtualModuleOptions } from './types.js';\n\nconst babelCwd = new URL('../', import.meta.url);\n\n/**\n * @deprecated Import `getContainerRenderer` from `@astrojs/preact/container-renderer` instead.\n */\nexport function getContainerRenderer(): AstroRenderer {\n\tconsole.warn(\n\t\t'[@astrojs/preact] Importing `getContainerRenderer` from `@astrojs/preact` is deprecated. Import it from `@astrojs/preact/container-renderer` instead.',\n\t);\n\treturn getContainerRendererImpl();\n}\n\nfunction optionsPlugin(include: Options['include'], exclude: Options['exclude']): Plugin {\n\tconst virtualModule = 'astro:preact:opts';\n\tconst virtualModuleId = '\\0' + virtualModule;\n\treturn {\n\t\tname: '@astrojs/preact:opts',\n\t\tresolveId: {\n\t\t\tfilter: {\n\t\t\t\tid: new RegExp(`^${virtualModule}$`),\n\t\t\t},\n\t\t\thandler() {\n\t\t\t\treturn virtualModuleId;\n\t\t\t},\n\t\t},","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/integrations/preact/src/index.ts#L1-L36","documentation":"@astrojs/preact kept a getContainerRenderer() re-export on its package root for backward compatibility, but container rendering APIs now live in the subpath export. Calling the root-level shim prints this console.warn and forwards to the real implementation from ./container-renderer.js, so output is correct but the import is scheduled for removal.","triggerScenarios":" Code calls getContainerRenderer imported from '@astrojs/preact' (root), typically in a custom Express/Hono/Nest SSR entry: import { getContainerRenderer } from '@astrojs/preact'; followed by renderToStreamingMarkup / experimental_AstroContainer usage.","commonSituations":" Upgrading @astrojs/preact to a version that moved container APIs to @astrojs/preact/container-renderer while keeping old manual-SSR code; copying older container-rendering examples from the Astro docs or blog posts.","solutions":["Change the import specifier: import { getContainerRenderer } from '@astrojs/preact/container-renderer';","Update TypeScript moduleResolution settings if the subpath types are not found (bundler/node16 resolution recommended).","Re-run the container render; the warning should disappear while output stays identical."],"exampleFix":"// before\nimport { getContainerRenderer } from '@astrojs/preact';\nconst Container = await experimental_AstroContainer.create();\nContainer.addRenderer({ name: 'preact', serverEntrypoint: await getContainerRenderer() });\n\n// after\nimport { getContainerRenderer } from '@astrojs/preact/container-renderer';\nconst Container = await experimental_AstroContainer.create();\nContainer.addRenderer({ name: 'preact', serverEntrypoint: await getContainerRenderer() });","handlingStrategy":"validation","validationCode":"// CI guard: reject root-level getContainerRenderer imports\nconst files = await glob('server/**/*.ts');\nfor (const f of files) {\n  const src = await readFile(f, 'utf8');\n  if (/from ['\"]@astrojs\\/preact['\"].*getContainerRenderer|getContainerRenderer.*from ['\"]@astrojs\\/preact['\"]/s.test(src)) {\n    throw new Error(`${f}: import getContainerRenderer from '@astrojs/preact/container-renderer'`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always import container APIs from the /container-renderer subpath.","Register the renderer once at container creation, not per request, to avoid repeated warnings.","Pin ESLint no-restricted-imports patterns that ban getContainerRenderer from the root entry."],"tags":["preact","deprecation","container-renderer","ssr","import-path"],"backgroundTag":"deprecated-import-path","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}