{"record":{"id":"70f6b2d35f8aec20","repo":"sveltejs/svelte","slug":"experimental-async-required","errorCode":"experimental_async_required","errorMessage":"experimental_async_required\nCannot use `${name}(...)` unless the `experimental.async` compiler option is `true`\nhttps://svelte.dev/e/experimental_async_required","messagePattern":"experimental_async_required\nCannot use `(.+?)\\(\\.\\.\\.\\)` unless the `experimental\\.async` compiler option is `true`\nhttps://svelte\\.dev/e/experimental_async_required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/svelte/src/internal/shared/errors.js","lineNumber":18,"sourceCode":"/* This file is generated by scripts/process-messages/index.js. Do not edit! */\n\nimport { DEV } from 'esm-env';\n\n/**\n * Cannot use `%name%(...)` unless the `experimental.async` compiler option is `true`\n * @param {string} name\n * @returns {never}\n */\nexport function experimental_async_required(name) {\n\tif (DEV) {\n\t\tconst error = new Error(`experimental_async_required\\nCannot use \\`${name}(...)\\` unless the \\`experimental.async\\` compiler option is \\`true\\`\\nhttps://svelte.dev/e/experimental_async_required`);\n\n\t\terror.name = 'Svelte error';\n\n\t\tthrow error;\n\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/experimental_async_required`);\n\t}\n}\n\n/**\n * Cannot use `{@render children(...)}` if the parent component uses `let:` directives. Consider using a named snippet instead\n * @returns {never}\n */\nexport function invalid_default_snippet() {\n\tif (DEV) {\n\t\tconst error = new Error(`invalid_default_snippet\\nCannot use \\`{@render children(...)}\\` if the parent component uses \\`let:\\` directives. Consider using a named snippet instead\\nhttps://svelte.dev/e/invalid_default_snippet`);\n\n\t\terror.name = 'Svelte error';\n\n\t\tthrow error;\n\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/invalid_default_snippet`);\n\t}\n}","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/sveltejs/svelte/blob/20b341f10048cf1016a2028ac7eee5595cfef6a5/packages/svelte/src/internal/shared/errors.js#L1-L36","documentation":"Svelte's experimental async component support (e.g. top-level `await` in a component `<script>`) must be opted into via the `experimental.async` compiler option. Without it, the compiler emits a call to `experimental_async_required(name)`, which throws at runtime when the async feature is invoked. The message names the specific feature (`%name%`) that triggered it.","triggerScenarios":"Using an async-only Svelte feature — such as top-level `await` in a `.svelte` `<script>` — without `compilerOptions.experimental.async = true` in `svelte.config.js` or the Vite plugin config. The compiled output calls the guard function, which throws.","commonSituations":"Following docs/tutorials that assume experimental async is enabled; upgrading Svelte where the flag reset to its default `false`; using a library that depends on async components.","solutions":["Enable the option: in `svelte.config.js` set `export default { compilerOptions: { experimental: { async: true } } }`.","Remove the async feature and refactor top-level `await` into `onMount`/`$effect` with explicit loading state.","Verify the compiler picks up the config (Vite/SvelteKit plugin options) — rebuild after changing config."],"exampleFix":"// before — svelte.config.js\nexport default { compilerOptions: {} };\n// after\nexport default { compilerOptions: { experimental: { async: true } } };","handlingStrategy":"validation","validationCode":"// assert experimental.async is enabled before building\nimport { readFileSync } from 'fs';\nconst cfg = readFileSync('svelte.config.js', 'utf8');\nif (!/experimental\\s*:\\s*\\{\\s*async\\s*:\\s*true/.test(cfg)) {\n\tthrow new Error('experimental.async must be true for async components');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable experimental.async when using top-level await in components.","Document the flag in project onboarding.","Add a config assertion to CI builds.","Rebuild after changing compiler options — the flag is compile-time."],"tags":["compiler","async","experimental","config","svelte5"],"backgroundTag":null,"analyzedSha":"20b341f10048cf1016a2028ac7eee5595cfef6a5","analyzedAt":"2026-08-12T23:37:30.399Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}