Vue · VUE0012

Avoid random, current-time, or locale-dependent SSR render values

Flags random numbers, the current time, and default-locale or local-time-zone formatting in server-rendered Vue output.
VUE0012vite-doctor/vuessrwarnSuggestion

Run this rule

pnpm vite-doctor . --framework vue --rules vue/ssr/no-random-or-local-time-render

Why it matters

Math.random(), Date.now() and new Date() return a different value on the server and in the browser, and toLocaleString(), toLocaleDateString(), Intl.DateTimeFormat and Intl.NumberFormat without an explicit locale or timeZone format with the settings of the process that renders. The first client render then differs from the server HTML and Vue logs a hydration mismatch. Doctor checks SFC scripts, and in .ts and .tsx files the values inside render functions, h() arguments and JSX, including values that a helper from the same file or a relative import computes.

Render a value the server and the client agree on, such as a UTC date formatted with an explicit locale and timeZone, and switch to the local or relative value in onMounted(). Use useId() for ids, or isolate the node with data-allow-mismatch.

Example

Render a stable date, then the local one after mount

Before

return () => h("time", { title: new Date(props.at).toLocaleString() }, timeAgo(props.at))

After

const mounted = ref(false)
onMounted(() => { mounted.value = true })
return () => h("time", { title: new Date(props.at).toISOString() }, mounted.value ? timeAgo(props.at) : new Date(props.at).toISOString().slice(0, 10))
Copyright © 2026