slidevjs/slidev · error · Error

`loadTheme` is no longer supported.

Error message

`loadTheme` is no longer supported.

What it means

The legacy shikiContext.loadTheme() method is a stub that always throws. It was removed when Slidev migrated to a Shiki version where themes are supplied declaratively via the theme/themes options instead of being loaded imperatively at runtime.

Source

Thrown at packages/client/setup/shiki-options.ts:12

// This module also runs in the Node.js environment

import type { ResolvedSlidevUtils, ShikiContext, ShikiSetupReturn } from '@slidev/types'
import type { LanguageInput, ThemeInput, ThemeRegistrationAny } from 'shiki'
import { objectMap } from '@antfu/utils'
import { red, yellow } from 'ansis'
import { bundledLanguages, bundledThemes } from 'shiki'

export const shikiContext: ShikiContext = {
  /** @deprecated */
  loadTheme() {
    throw new Error('`loadTheme` is no longer supported.')
  },
}

export function resolveShikiOptions(options: (ShikiSetupReturn | void)[]) {
  const mergedOptions: Record<string, any> = Object.assign({}, ...options)

  if ('theme' in mergedOptions && 'themes' in mergedOptions)
    delete mergedOptions.theme

  // Rename theme to themes when provided in multiple themes format, but exclude when it's a theme object.
  if (mergedOptions.theme && typeof mergedOptions.theme !== 'string' && !mergedOptions.theme.name && !mergedOptions.theme.tokenColors) {
    mergedOptions.themes = mergedOptions.theme
    delete mergedOptions.theme
  }

  // No theme at all, apply the default
  if (!mergedOptions.theme && !mergedOptions.themes) {
    mergedOptions.themes = {

View on GitHub (pinned to 0d798ace58)

Solutions

  1. Replace loadTheme() calls with a ShikiSetupReturn that declares themes via the themes/theme option
  2. Upgrade the offending theme/addon to a current version
  3. Remove the call if your theme is already declared in the shiki setup

Example fix

// before
shikiContext.loadTheme('my-theme')
// after
return { theme: { name: 'my-theme', ... } }
Defensive patterns

Strategy: type-guard

Validate before calling

if (typeof shikiContext.loadTheme === 'function') {
  // legacy stub: avoid calling it; declare themes via ShikiSetupReturn instead
}

Type guard

function hasModernShikiSetup(setup: any): setup is { theme?: string; themes?: Record<string, string> } {
  return 'theme' in setup || 'themes' in setup
}

Prevention

When it happens

Trigger: A theme, addon, or user setup calling shikiContext.loadTheme(name) - typically old code written against a pre-migration Slidev API.

Common situations: Outdated theme or addon not yet updated for the current Slidev; copy-pasted setup code from old tutorials; custom integrations that predate the themes-object API.

Related errors


AI-assisted analysis of slidevjs/slidev@0d798ace58 (2026-08-12). Data as JSON: /api/errors/84db432adaee31f6. Report an issue: GitHub.