sveltejs/kit · error

Can only call updated.check() in the browser

Error message

Can only call updated.check() in the browser

What it means

On the server, `$app/state`'s `updated` object is a stub: `current` is always `false` and `check()` throws, because update detection depends on comparing deployed build assets, which is a browser-only operation. Call `updated.check()` (or read `updated.current`) only in the browser.

Source

Thrown at packages/kit/src/runtime/app/state/server.js:64

		return (DEV ? context_dev('page.url') : context()).page.url;
	}
};

export const navigating = {
	from: null,
	to: null,
	type: null,
	willUnload: null,
	delta: null,
	complete: null
};

export const updated = {
	get current() {
		return false;
	},
	check: () => {
		throw new Error('Can only call updated.check() in the browser');
	}
};

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Call `updated.check()` inside `onMount` or after `browser` is true (`import { browser } from '$app/environment'`)
  2. Use `updated.current` reactively in the component instead of eagerly calling check() on the server
  3. Guard server execution: `if (browser) updated.check();`

Example fix

// before
const canUpdate = updated.check();
// after
import { onMount } from 'svelte';
let canUpdate = false;
onMount(() => { canUpdate = updated.check(); });
Defensive patterns

Strategy: type-guard

Validate before calling

import { browser } from '$app/environment';
if (browser) {
  const canUpdate = updated.check();
}

Type guard

const canCallCheck = () => typeof window !== 'undefined' && typeof document !== 'undefined';

Try / catch

try {
  const result = updated.check();
} catch (e) {
  if (e.message.includes('in the browser')) {
    const result = false; // server default: not updated
  } else throw e;
}

Prevention

When it happens

Trigger: Calling `updated.check()` during SSR (component runs on server), in a `load` function, in a server hook, or in a universal component without guarding for `browser`.

Common situations: Rendering a 'new version available' indicator component that calls `updated.check()` in its initialization on the server; shared util calling `updated.check()` during SSR.

Related errors


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