{"record":{"id":"6ee04c2f5b8aeac9","repo":"sveltejs/svelte","slug":"invalid-snippet-arguments","errorCode":"invalid_snippet_arguments","errorMessage":"invalid_snippet_arguments\nA snippet function was passed invalid arguments. Snippets should only be instantiated via `{@render ...}`\nhttps://svelte.dev/e/invalid_snippet_arguments","messagePattern":"invalid_snippet_arguments\nA snippet function was passed invalid arguments\\. Snippets should only be instantiated via `(.+?)`\nhttps://svelte\\.dev/e/invalid_snippet_arguments","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/svelte/src/internal/shared/errors.js","lineNumber":50,"sourceCode":"\t\tthrow error;\n\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/invalid_default_snippet`);\n\t}\n}\n\n/**\n * A snippet function was passed invalid arguments. Snippets should only be instantiated via `{@render ...}`\n * @returns {never}\n */\nexport function invalid_snippet_arguments() {\n\tif (DEV) {\n\t\tconst error = new Error(`invalid_snippet_arguments\\nA snippet function was passed invalid arguments. Snippets should only be instantiated via \\`{@render ...}\\`\\nhttps://svelte.dev/e/invalid_snippet_arguments`);\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_snippet_arguments`);\n\t}\n}\n\n/**\n * An invariant violation occurred, meaning Svelte's internal assumptions were flawed. This is a bug in Svelte, not your app — please open an issue at https://github.com/sveltejs/svelte, citing the following message: \"%message%\"\n * @param {string} message\n * @returns {never}\n */\nexport function invariant_violation(message) {\n\tif (DEV) {\n\t\tconst error = new Error(`invariant_violation\\nAn invariant violation occurred, meaning Svelte's internal assumptions were flawed. This is a bug in Svelte, not your app — please open an issue at https://github.com/sveltejs/svelte, citing the following message: \"${message}\"\\nhttps://svelte.dev/e/invariant_violation`);\n\n\t\terror.name = 'Svelte error';\n\n\t\tthrow error;\n\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/invariant_violation`);\n\t}","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/sveltejs/svelte/blob/20b341f10048cf1016a2028ac7eee5595cfef6a5/packages/svelte/src/internal/shared/errors.js#L32-L68","documentation":"Svelte 5 snippets must be instantiated only via `{@render ...}` in markup, not called as ordinary functions. This DEV error fires when a snippet function receives invalid arguments — typically because it was invoked directly in JS or passed to code that calls it as a callback. The runtime detects the misuse and throws.","triggerScenarios":"Calling a snippet function directly (`snippet(arg)`) instead of `{@render snippet(arg)}`; passing a snippet to an event handler/utility that invokes it; calling a snippet outside its render context.","commonSituations":"Treating snippets like regular functions (common when learning Svelte 5 snippets); refactoring `{@render}` blocks into helpers that accidentally call the snippet; passing `children` to a handler that calls it.","solutions":["Render snippets only via `{@render snippet(...)}` in markup, never call them in `<script>`.","For reusable renderable content, define a snippet with `{#snippet}` and reference it with `{@render}`.","Audit callbacks that receive snippets — ensure they use `{@render}`, not direct invocation."],"exampleFix":"<!-- before -->\n<script>\n\tfunction handleClick() { children(); } // invalid: calls snippet as a function\n</script>\n<button onclick={handleClick}>click</button>\n<!-- after -->\n{@render children()}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Render snippets only with `{@render snippet(...)}`.","Never call snippet functions inside `<script>`.","Do not pass snippets as regular callbacks to be invoked.","Treat `{@render}` as the only legal snippet entry point."],"tags":["snippets","render","svelte5","dev-only"],"backgroundTag":null,"analyzedSha":"20b341f10048cf1016a2028ac7eee5595cfef6a5","analyzedAt":"2026-08-12T23:37:30.399Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}