sveltejs/kit · error · Error
Cannot call a command (${__.name}) during server-side render
Error message
Cannot call a command (${__.name}) during server-side rendering What it means
Runtime guard around a remote command: the request-store state marks the current execution as server-side rendering (is_in_render). Commands mutate state and require a real mutative request, so invoking one during SSR (e.g. at component init while rendering) is rejected.
Source
Thrown at packages/kit/src/runtime/app/server/remote/command.js:82
/** @type {RemoteCommand<Input, Output> & { __: RemoteCommandInternals }} */
const wrapper = (arg) => {
const { event, state } = get_request_store();
if (
!MUTATIVE_METHODS.includes(event.request.method) ||
state.is_in_remote_query ||
state.is_in_remote_prerender
) {
const violation =
state.is_in_remote_query || state.is_in_remote_prerender
? `inside a query or prerender function`
: `from a ${event.request.method} handler`;
throw new Error(`Cannot call a command (${__.name}) ${violation}`);
}
if (state.is_in_render) {
throw new Error(`Cannot call a command (${__.name}) during server-side rendering`);
}
const promise = Promise.resolve(
run_remote_function(event, state, true, () => validate(arg), fn)
);
// @ts-expect-error
promise.updates = () => {
throw new Error(`Cannot call '${__.name}(...).updates(...)' on the server`);
};
return /** @type {ReturnType<RemoteCommand<Input, Output>>} */ (promise);
};
Object.defineProperty(wrapper, '__', { value: __ });
// On the server, pending is always 0
Object.defineProperty(wrapper, 'pending', {View on GitHub (pinned to 03f1687fe6)
Solutions
- Move the command call into a user-triggered event handler (form submit, button click) or a load/query function
- Avoid invoking commands during component initialization on the server
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/kit/src/runtime/app/server/remote/command.js:82 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/0d2e09c228f86538.
Report an issue: GitHub.