sveltejs/svelte · error · Error

invalid_snippet_arguments

invalid_snippet_arguments

Error message

invalid_snippet_arguments
A snippet function was passed invalid arguments. Snippets should only be instantiated via `{@render ...}`
https://svelte.dev/e/invalid_snippet_arguments

What it means

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.

Source

Thrown at packages/svelte/src/internal/shared/errors.js:50

		throw error;
	} else {
		throw new Error(`https://svelte.dev/e/invalid_default_snippet`);
	}
}

/**
 * A snippet function was passed invalid arguments. Snippets should only be instantiated via `{@render ...}`
 * @returns {never}
 */
export function invalid_snippet_arguments() {
	if (DEV) {
		const 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`);

		error.name = 'Svelte error';

		throw error;
	} else {
		throw new Error(`https://svelte.dev/e/invalid_snippet_arguments`);
	}
}

/**
 * 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%"
 * @param {string} message
 * @returns {never}
 */
export function invariant_violation(message) {
	if (DEV) {
		const 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`);

		error.name = 'Svelte error';

		throw error;
	} else {
		throw new Error(`https://svelte.dev/e/invariant_violation`);
	}

View on GitHub (pinned to 20b341f100)

Solutions

  1. Render snippets only via `{@render snippet(...)}` in markup, never call them in `<script>`.
  2. For reusable renderable content, define a snippet with `{#snippet}` and reference it with `{@render}`.
  3. Audit callbacks that receive snippets — ensure they use `{@render}`, not direct invocation.

Example fix

<!-- before -->
<script>
	function handleClick() { children(); } // invalid: calls snippet as a function
</script>
<button onclick={handleClick}>click</button>
<!-- after -->
{@render children()}
Defensive patterns

Strategy: type-guard

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of sveltejs/svelte@20b341f100 (2026-08-12). Data as JSON: /api/errors/6ee04c2f5b8aeac9. Report an issue: GitHub.