React CodeMirror

A fully-typed React component and hook for embedding the CodeMirror 6 code editor with themes and language extensions.

Library
npm
v4.25.12
2,257 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
69 /100 Good
Development Activity 52
Maintenance 64
Community 60
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
79 /100 Good
Architecture 80
Code Quality 82
Innovation 74
Learning Curve 78

@uiw/react-codemirror wraps CodeMirror 6 in a single React component so applications can drop in a syntax-highlighted, extensible code editor without hand-rolling the imperative CodeMirror setup themselves. It exposes both a <CodeMirror /> component and a useCodeMirror hook, forwarding CodeMirror’s extension system directly through props so language support, linting, autocompletion, and custom themes are all configured declaratively.

The package is the hub of a larger monorepo of companion packages — dozens of prebuilt themes (Dracula, GitHub, Monokai, Nord, VS Code, and more), reusable extensions (basic setup, hyperlinks, mentions, zebra stripes, relative line numbers), and a separate merge-view package for side-by-side diffing — all versioned and released together, letting consumers pull in only what they need.

What You Get

  • A <CodeMirror /> component with value, onChange, theme, extensions, and sizing props that map directly onto CodeMirror 6 concepts
  • A standalone useCodeMirror hook for teams that want to control the container and lifecycle themselves
  • A ReactCodeMirrorRef imperative handle exposing the live EditorView and EditorState for advanced integrations
  • Companion packages for dozens of prebuilt syntax themes, language extension bundles, and a side-by-side merge/diff editor
  • Full TypeScript typings generated alongside the source, including typed extension and theme options

Common Use Cases

  • Embedding a syntax-highlighted code editor in developer tools, admin panels, or documentation playgrounds
  • Building in-browser IDEs or code-sandbox experiences with live language support (JS, Python, Go, Markdown, SQL, and more via CodeMirror language packages)
  • Adding a themeable JSON/YAML/config editor to a settings or CMS UI
  • Rendering a read-only, syntax-highlighted code viewer with custom decorations or line highlighting
  • Building diffing/merge UIs via the companion react-codemirror-merge package

Under The Hood

Architecture — The package centers on useCodeMirror (core/src/useCodeMirror.ts), a hook that owns the CodeMirror EditorState/EditorView lifecycle via useLayoutEffect/useEffect. It builds an extension array by merging an updateListener (which drives onChange/onStatistics/onUpdate), a dimension theme computed from height/width props, and the caller’s own extensions prop, then reconciles changes to that array on prop changes via StateEffect.reconfigure. The <CodeMirror /> component (core/src/index.tsx) is a thin forwardRef wrapper that renders the mount <div>, delegates all state to the hook, and exposes editor/state/view through useImperativeHandle. External value changes are diffed against the live document and dispatched as annotated transactions to avoid re-triggering onChange in a loop.

Tech Stack — Written in TypeScript, built with tsbb (a Babel/Rollup-based bundler) into separate cjs/esm outputs, and managed as a Lerna monorepo (lerna.json, npm workspaces spanning core, themes/*, extensions/*, and merge). CodeMirror 6 packages (@codemirror/state, @codemirror/view, @codemirror/commands, @codemirror/theme-one-dark) and React are declared as peer dependencies, so consumers control their own CodeMirror and React versions; the sibling @uiw/codemirror-extensions-basic-setup package is a regular dependency providing the default keymap/gutter/search extension bundle.

Code Quality — The core/src/__tests__/index.test.tsx suite uses Testing Library and react-test-renderer, and goes to real lengths to make CodeMirror work under JSDOM — mocking Range.getClientRects, IntersectionObserver, ResizeObserver, and MutationObserver, and stubbing element layout getters — indicating the maintainers actively fight the gap between a real browser and CodeMirror 6’s layout assumptions rather than skipping coverage. Source files are small and single-purpose (useCodeMirror.ts, getDefaultExtensions.ts, timeoutLatch.ts, utils.ts), each under 210 lines, with consistent TypeScript interfaces for every prop surface.

API Design — The public API stays close to CodeMirror 6’s own vocabulary (extensions, EditorView, EditorState) rather than inventing a parallel abstraction, which keeps the learning curve low for anyone who has read CodeMirror’s own docs, while props like theme: 'light' | 'dark' | 'none' | Extension and basicSetup: boolean | BasicSetupOptions give a simple default path plus an escape hatch into full CodeMirror configuration. Getting started requires only value, onChange, and an extensions array for language support, as shown directly in the README’s copy-pasteable example.

Used by 113 apps in this directory

TypeScript
62%
Other

Flowise

AI Development · Automation · Developer Tools

55,521

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
75
Repo Health
77
Technical
63
Dependency
Built with
TypeScript 62%
JavaScript 27%
Updated 2 months ago
TypeScript
62%
Other

Flowise

AI Development · Automation · Developer Tools

55,521

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
75
Repo Health
77
Technical
63
Dependency
Built with
TypeScript 62%
JavaScript 27%
Updated 2 months ago
TypeScript
62%
Other

Flowise

AI Development · Automation · Developer Tools

55,521

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
75
Repo Health
77
Technical
63
Dependency
Built with
TypeScript 62%
JavaScript 27%
Updated 2 months ago
TypeScript
63%
MIT

Ghost

Blogging · CMS

55,598

Open source headless Node.js CMS for professional publishing, paid memberships, and newsletters with a fully owned audience.

View details
96
Repo Health
85
Technical
64
Dependency
Built with
TypeScript 63%
JavaScript 35%
Updated 1 weeks ago
TypeScript
63%
MIT

Ghost

Blogging · CMS

55,598

Open source headless Node.js CMS for professional publishing, paid memberships, and newsletters with a fully owned audience.

View details
96
Repo Health
85
Technical
64
Dependency
Built with
TypeScript 63%
JavaScript 35%
Updated 1 weeks ago
Go
70%
MIT

Gotify

Developer Tools · Monitoring

16,111

A lightweight, self-hosted push notification server that sends and receives messages in real time over WebSocket, with a sleek web UI and a native Go plugin system.

View details
90
Repo Health
74
Technical
70
Dependency
Built with
Go 70%
TypeScript 29%
Updated 1 weeks ago
Go
70%
MIT

Gotify

Developer Tools · Monitoring

16,111

A lightweight, self-hosted push notification server that sends and receives messages in real time over WebSocket, with a sleek web UI and a native Go plugin system.

View details
90
Repo Health
74
Technical
70
Dependency
Built with
Go 70%
TypeScript 29%
Updated 1 weeks ago
TypeScript
47%
AGPL 3.0

Grafana

Analytics · Monitoring

77,469

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
63
Dependency
Built with
TypeScript 47%
Go 47%
Updated 6 days ago
Go
62%
Apache 2.0

Harness Open Source

Code Editors · Developer Tools · Devops

38,684

A unified open source DevOps platform combining Git hosting, CI/CD pipelines, cloud development environments, and artifact registries in a single self-hosted system.

View details
90
Repo Health
79
Technical
64
Dependency
Built with
Go 62%
TypeScript 33%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers