# @astrojs/prism

> Add Prism syntax highlighting support to your Astro site

Latest version **4.0.2** (published 2026-05-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @astrojs/prism
pnpm add @astrojs/prism
yarn add @astrojs/prism
bun add @astrojs/prism
```

## Health

**Score 70/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 4.0.2 |
| Published | 2026-05-13 |
| First published | 2021-06-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=22.12.0 |
| Dependencies | 1 |
| Unpacked size | 14 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 62632 |
| Author | withastro |
| Maintainers | fredkschott, matthewp |
| Keywords | astro, astro-component |

## Links

- npm: https://www.npmjs.com/package/@astrojs/prism
- Repository: https://github.com/withastro/astro
- Homepage: https://docs.astro.build/en/reference/api-reference/#prism-
- Issues: https://github.com/withastro/astro/issues
- npm.io page: https://npm.io/package/@astrojs/prism

## Dependencies (1)

- [prismjs](https://npm.io/package/prismjs.md) ^1.30.0

## Recent versions

- 4.0.2 (latest) — 2026-05-13
- 4.0.0-beta.2 (beta) — 2026-01-23
- 4.0.0-alpha.0 (alpha) — 2025-11-10
- 0.0.0-10745-20240410180016 (experimental--10745) — 2024-04-10
- 3.0.0-rc.1 (rc) — 2023-08-22
- 0.0.0-vercel-json-20230313201834 (next--vercel-json) — 2023-03-13
- 0.0.0-experimental-assets-20230307131344 (next--experimental-assets) — 2023-03-07
- 0.0.0-cloudcannon-fix-20230306211609 (next--cloudcannon-fix) — 2023-03-06
- 0.4.1-next.0 (next) — 2022-03-24
- 4.0.1 — 2026-03-18
- 4.0.0 — 2026-03-10
- 4.0.0-beta.1 — 2026-01-13
- 3.3.0 — 2025-05-22
- 3.2.0 — 2024-12-03
- 3.2.0-beta.0 — 2024-11-27
- … 26 more at https://npm.io/package/@astrojs/prism/versions

## README

# @astrojs/prism

Supports Prism highlighting in Astro projects

## Component

This package exports a component to support highlighting inside an Astro file. Example:

```astro
---
import { Prism } from '@astrojs/prism';
---

<Prism lang="js" code={`const foo = 'bar';`} />
```

## Internal

This package exports a `runHighlighterWithAstro` function to highlight while making sure the Astro language is loaded beforehand

```typescript
import { runHighlighterWithAstro } from '@astrojs/prism';

runHighlighterWithAstro(
  `
  ---
    const helloAstro = 'Hello, Astro!';
  ---

  <div>{helloAstro}</div>
`,
  'astro',
);
```

---
_Source: https://npm.io/package/@astrojs/prism · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
