{"record":{"id":"886b17f8c8fe97fc","repo":"withastro/astro","slug":"serveronlymodule-886b17","errorCode":"ServerOnlyModule","errorMessage":"The \"astro:config/server\" module is only available server-side.","messagePattern":"The \"astro:config/server\" module is only available server-side\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/manifest/virtual-module.ts","lineNumber":88,"sourceCode":"\t\t\t\t\treturn RESOLVED_VIRTUAL_CLIENT_ID;\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\tload: {\n\t\t\tfilter: {\n\t\t\t\tid: new RegExp(`^(${RESOLVED_VIRTUAL_SERVER_ID}|${RESOLVED_VIRTUAL_CLIENT_ID})$`),\n\t\t\t},\n\t\t\thandler(id) {\n\t\t\t\tif (id === RESOLVED_VIRTUAL_CLIENT_ID) {\n\t\t\t\t\t// astro:config/client inlines values directly from settings instead of\n\t\t\t\t\t// importing from virtual:astro:manifest to avoid pulling server-only\n\t\t\t\t\t// virtual modules (virtual:astro:routes, virtual:astro:pages) into the\n\t\t\t\t\t// client environment where they are not available.\n\t\t\t\t\treturn { code: clientConfigCode };\n\t\t\t\t}\n\t\t\t\tif (id === RESOLVED_VIRTUAL_SERVER_ID) {\n\t\t\t\t\tif (this.environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.client) {\n\t\t\t\t\t\tthrow new AstroError({\n\t\t\t\t\t\t\t...AstroErrorData.ServerOnlyModule,\n\t\t\t\t\t\t\tmessage: AstroErrorData.ServerOnlyModule.message(VIRTUAL_SERVER_ID),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tconst code = `\nimport { manifest } from '${SERIALIZED_MANIFEST_ID}'\nimport { fromRoutingStrategy } from \"astro/app\";\n\nlet i18n = undefined;\nif (manifest.i18n) {\n i18n = {\n   defaultLocale: manifest.i18n.defaultLocale,\n   locales: manifest.i18n.locales,\n   routing: fromRoutingStrategy(manifest.i18n.strategy, manifest.i18n.fallbackType),\n   fallback: manifest.i18n.fallback,\n   domains: manifest.i18n.domains,\n };\n}","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/manifest/virtual-module.ts#L70-L106","documentation":"The virtual module `astro:config/server` exposes the Astro config to server-side code (it reads the serialized manifest). It only exists in server environments; when it is resolved from the client environment the manifest Vite plugin throws ServerOnlyModule, meaning you imported `astro:config/server` (directly or transitively) into browser-bound code. Use `astro:config/client` there - it inlines only the public subset of config values.","triggerScenarios":"Importing astro:config/server inside an inline `<script>` tag or a `client:*` component; a shared utility module that reads config and is imported by both server endpoints and client scripts; importing it in a static page's client bundle.","commonSituations":"Wanting base/trailingSlash config in client-side navigation helpers and grabbing the wrong module; refactors that move a config-reading helper into a shared file; SSR-to-static migrations pulling formerly server-only imports into the client graph.","solutions":["Switch the import to `astro:config/client` in browser-reachable code.","Split shared config helpers into server and client variants so server config never enters the client graph.","Pass needed config values from server components as props instead of importing the server module in client code."],"exampleFix":"// before - client-bundled module\nimport { config } from 'astro:config/server';\n\n// after\nimport { config } from 'astro:config/client';","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// in shared code: pick the right virtual module for the environment\nconst getConfig = import.meta.env.SSR\n  ? () => import('astro:config/server')\n  : () => import('astro:config/client');","tryCatchPattern":null,"preventionTips":["Use astro:config/client in any module that can be bundled for the browser.","Keep server-config reads in files only imported by endpoints, middleware, or server components.","Pass config values as props from server components instead of importing the server module in client code."],"tags":["config","server-only","virtual-module","bundling"],"backgroundTag":"server-only-module-import","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}