sveltejs/kit · error · Error

Cannot call validate() on the server

Error message

Cannot call validate() on the server

What it means

Server-side stub on the remote form instance: validate() is a client-only method that runs pre-submit validation in the browser. When the form object is created on the server (e.g. during SSR), calling validate() is replaced by this throwing stub because there is no DOM form to validate.

Source

Thrown at packages/kit/src/runtime/app/server/remote/form.js:229

		});

		// On the server, pending is always 0
		Object.defineProperty(instance, 'pending', {
			get: () => 0
		});

		Object.defineProperty(instance, 'submitted', {
			get: () => false
		});

		Object.defineProperty(instance, 'preflight', {
			// preflight is a noop on the server
			value: () => instance
		});

		Object.defineProperty(instance, 'validate', {
			value: () => {
				throw new Error('Cannot call validate() on the server');
			}
		});

		Object.defineProperty(instance, 'submit', {
			value: () => {
				throw new Error('Cannot call submit() on the server');
			}
		});

		Object.defineProperty(instance, 'element', {
			get: () => null
		});

		if (key == undefined) {
			Object.defineProperty(instance, 'for', {
				/** @type {RemoteForm<any, any>['for']} */
				value: (key) => {
					const { state } = get_request_store();

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Call validate() only in browser-side code, e.g. inside an event handler after mount
  2. Guard shared code with a browser environment check
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/kit/src/runtime/app/server/remote/form.js:229 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/247716e10175ef1a. Report an issue: GitHub.