Skip to content
FrameworkStyle

SSR and locale

Render translated player UI on the server without a flash of English

Video.js is English by default. Server-rendered pages that opt into another language should mount the relevant provider, output the correct lang, and supply translations on the first client render. Lazy loadLocale and browser translation fallback run after hydration, so controls briefly show English without preloaded copy.

Read Internationalization for provider resolution and merge order.

Set <html lang>

Render the document language on the server:

<html lang="es">

Register on the server

For a shipped pack, import its side-effect module in server bootstrap code before rendering players:

import '@videojs/html/i18n/locales/es/register';

For a custom pack, call registerI18n instead:

import { registerI18n } from '@videojs/html/i18n';
import es from './locales/es';

registerI18n('es', es);

The registry is module singleton state. Registration in server entry points carries into the client bundle when shared.

HTML custom elements

SSR HTML players should emit lang and wrap the player with <media-i18n>. Register packs in the entry module loaded before custom elements upgrade:

import '@videojs/html/video';
import '@videojs/html/i18n/locales/es/register';

What’s next?