@streamdown/code

Syntax highlighting for code blocks using Shiki.

The @streamdown/code plugin provides syntax highlighting for code blocks using Shiki.

  • Supports 200+ programming languages
  • Languages are lazy-loaded on demand
  • Dual theme support (light/dark mode)
  • Token caching for performance

Install

npm install @streamdown/code

Tailwind CSS

Tailwind v4

Add the following @source directive to your globals.css or main CSS file:

globals.css
@source "../node_modules/@streamdown/code/dist/*.js";

The path must be relative from your CSS file to the node_modules folder containing @streamdown/code. In a monorepo, adjust the number of ../ segments to reach the root node_modules.

Tailwind v3

Add @streamdown/code to your content array in tailwind.config.js:

tailwind.config.js
module.exports = {
  content: [
    "./app/**/*.{js,ts,jsx,tsx,mdx}",
    "./node_modules/@streamdown/code/dist/*.js",
  ],
  // ... rest of your config
};

In a monorepo, adjust the path to reach the root node_modules:

tailwind.config.js
module.exports = {
  content: [
    "./app/**/*.{js,ts,jsx,tsx,mdx}",
    "../../node_modules/@streamdown/code/dist/*.js",
  ],
  // ... rest of your config
};

Usage

import { code } from '@streamdown/code';

<Streamdown plugins={{ code }}>
  {markdown}
</Streamdown>

Custom configuration

import { createCodePlugin } from '@streamdown/code';

const code = createCodePlugin({
  themes: ['github-light', 'github-dark'], // [light, dark]
});

See Code Blocks for details on rendering behavior, line numbers, and copy buttons.

On this page

GitHubEdit this page on GitHub