{"record":{"id":"d1e160f6ead91305","repo":"withastro/astro","slug":"astrojs-svelte-importing-getcontainerrenderer","errorCode":null,"errorMessage":"[@astrojs/svelte] Importing `getContainerRenderer` from `@astrojs/svelte` is deprecated. Import it from `@astrojs/svelte/container-renderer` instead.","messagePattern":"\\[@astrojs/svelte\\] Importing `getContainerRenderer` from `@astrojs/svelte` is deprecated\\. Import it from `@astrojs/svelte/container-renderer` instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/integrations/svelte/src/index.ts","lineNumber":13,"sourceCode":"import type { Options } from '@sveltejs/vite-plugin-svelte';\nimport { svelte, vitePreprocess } from '@sveltejs/vite-plugin-svelte';\nimport type { AstroIntegration, AstroRenderer } from 'astro';\nimport { fileURLToPath } from 'node:url';\nimport type { Plugin } from 'vite';\nimport { crawlFrameworkPkgs } from 'vitefu';\nimport { getContainerRenderer as getContainerRendererImpl } from './container-renderer.js';\n\n/**\n * @deprecated Import `getContainerRenderer` from `@astrojs/svelte/container-renderer` instead.\n */\nexport function getContainerRenderer(): AstroRenderer {\n\tconsole.warn(\n\t\t'[@astrojs/svelte] Importing `getContainerRenderer` from `@astrojs/svelte` is deprecated. Import it from `@astrojs/svelte/container-renderer` instead.',\n\t);\n\treturn getContainerRendererImpl();\n}\n\nexport default function svelteIntegration(options?: Options): AstroIntegration {\n\treturn {\n\t\tname: '@astrojs/svelte',\n\t\thooks: {\n\t\t\t'astro:config:setup': async ({ config, updateConfig, addRenderer }) => {\n\t\t\t\taddRenderer(getContainerRendererImpl());\n\n\t\t\t\t// Svelte component libraries from `node_modules` must go through\n\t\t\t\t// Vite's transform pipeline because Node can't import `.svelte`\n\t\t\t\t// files. vite-plugin-svelte only marks a package as `noExternal`\n\t\t\t\t// when it has a `svelte` export condition; a package that merely\n\t\t\t\t// declares a `svelte` peer dependency is treated as a\n\t\t\t\t// \"semi-framework\" package and routed through `optimizeDeps`","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/integrations/svelte/src/index.ts#L1-L31","documentation":"@astrojs/svelte keeps a getContainerRenderer() export on its root entry purely for compatibility: it console.warns and returns the real renderer from ./container-renderer.js (which the integration itself uses via getContainerRendererImpl). The root export is deprecated in favor of the @astrojs/svelte/container-renderer subpath and will be removed in a future release.","triggerScenarios":" Manual SSR code imports { getContainerRenderer } from '@astrojs/svelte' (root) to feed experimental_AstroContainer, e.g. container.addRenderer({ name: 'svelte', serverEntrypoint: await getContainerRenderer() }).","commonSituations":" Upgrading @astrojs/svelte after container APIs were split into a subpath; older custom-server examples; renderers registered per-request so the warning prints repeatedly.","solutions":["Change the specifier to the subpath: import { getContainerRenderer } from '@astrojs/svelte/container-renderer';","Register the renderer once and reuse the container instance across requests.","Re-run and confirm no deprecation warning prints."],"exampleFix":"// before\nimport { getContainerRenderer } from '@astrojs/svelte';\nContainer.addRenderer({ name: 'svelte', serverEntrypoint: await getContainerRenderer() });\n\n// after\nimport { getContainerRenderer } from '@astrojs/svelte/container-renderer';\nContainer.addRenderer({ name: 'svelte', serverEntrypoint: await getContainerRenderer() });","handlingStrategy":"validation","validationCode":"const src = await readFile('server.ts', 'utf8');\nif (src.includes(\"{ getContainerRenderer } from '@astrojs/svelte'\")) {\n  throw new Error(\"Import getContainerRenderer from '@astrojs/svelte/container-renderer'\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Import container renderers from the /container-renderer subpath only.","Register the renderer once per process rather than per request.","Update custom SSR entries whenever @astrojs/svelte ships a major."],"tags":["svelte","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-14T05:17:10.506Z"}