A powerful and flexible code editor and syntax highlighter for React applications. Built with modern tools like CodeMirror 6 and Shiki.
Repo simonguo/react-code-view, read from GitHub 17 min ago. simonguo has not joined Take My Repo.
A patch release that refines example projects, improves documentation structure, and enhances developer experience.
All example projects (Vite, Webpack, Rollup, esbuild, Next.js) now feature a two-page structure for better clarity:
This separation makes it easier for developers to understand both usage patterns and choose the right approach for their needs.
.md module types in @react-code-view/unplugin/markdownresolveId hook to properly delegate to node-resolve pluginexamples/
โโโ vite/
โ โโโ src/
โ โ โโโ App.tsx # Navigation between pages
โ โ โโโ pages/
โ โ โ โโโ UnpluginPage.tsx # Markdown import demo
โ โ โ โโโ BasicPage.tsx # Traditional usage
โ โ โโโ docs/
โ โ โโโ unplugin-demo.md # Interactive examples
โโโ webpack/ # Same structure
โโโ rollup/ # Same structure
โโโ esbuild/ # Same structure
โโโ nextjs/
โโโ app/
โโโ unplugin/ # Route: /unplugin
โโโ basic/ # Route: /basic
โโโ layout.tsx # Shared navigation
Before (v3.0.0):
// Needed manual alias configuration resolve: { alias: { '@react-code-view/react': path.resolve(__dirname, '../../packages/react/src'), '@react-code-view/core': path.resolve(__dirname, '../../packages/core/src') } }
After (v3.0.1):
// Just add the plugin - pnpm workspace handles the rest import reactCodeView from '@react-code-view/unplugin/vite'; export default defineConfig({ plugins: [react(), reactCodeView()] });
Before:
// Each example needed local declaration file declare module '*.md' { const Component: React.FC; export default Component; }
After:
// Just reference the global types in tsconfig.json { "compilerOptions": { "types": ["@react-code-view/unplugin/markdown"] } }
react-code-view: 3.0.1@react-code-view/react: 3.0.1@react-code-view/core: 3.0.1@react-code-view/unplugin: 3.0.1No breaking changes! This is a drop-in replacement. However, you may want to:
A major overhaul that migrates react-code-view into a PNPM/Turbo monorepo, unifies build integrations, adds native markdown parsing, and refreshes the API/docs. This release is breaking compared to 2.6.1.
parseHTMLCodeView now natively parses and renders markdown files with embedded code blocks at runtime - no build step required!
.md files and CodeView automatically detects and renders code blocksparseHTML utility for consistent behavior@react-code-view/unplugin with useNativeParser: true (default) generates CodeView components.md files included in unplugin package?raw imports or unplugin// Runtime parsing (Vite example) import demoMarkdown from './demo.md?raw'; <CodeView dependencies={{ useState }}> {demoMarkdown} </CodeView> // Or use unplugin for build-time processing import UnpluginDemo from './unplugin-demo.md'; <UnpluginDemo theme="rcv-theme-default" dependencies={{ useState }} />
@react-code-view/unplugin package supporting Vite, Webpack, Rollup, esbuild, and Rspackwebpack-md-loader with modern, framework-agnostic solution.md files as React components with zero config@react-code-view/unplugin for all major bundlersCodeView is the default export from @react-code-view/reactimport '@react-code-view/react/styles/index.css' (Less removed)useCodeExecution with stable execute ref and updateCode aliasimport CodeView from 'react-code-view'; adjust named imports if you targeted old paths.import 'react-code-view/styles' (or specific CSS files). Remove Less imports.webpack-md-loader removed. Use the unified unplugin instead.Use @react-code-view/react as the primary entry and the new unplugin across bundlers.
Install
pnpm add @react-code-view/react @react-code-view/unplugin
Imports
import CodeView from '@react-code-view/react'; import { Renderer, MarkdownRenderer } from '@react-code-view/react'; // (Optional) re-exported convenience: // import CodeView from 'react-code-view';
Styles (CSS)
import '@react-code-view/react/styles/index.css';
Build plugin (Vite example)
// vite.config.js import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import reactCodeView from '@react-code-view/unplugin/vite'; export default defineConfig({ plugins: [react(), reactCodeView()] });
Webpack: @react-code-view/unplugin/webpack
Rollup: @react-code-view/unplugin/rollup
esbuild: @react-code-view/unplugin/esbuild
Rspack: @react-code-view/unplugin/rspack
Hook usage (useCodeExecution)
import { useCodeExecution } from '@react-code-view/react'; const { element, error, code, updateCode, execute } = useCodeExecution( initialCode, { dependencies: { Button }, transformOptions: { transforms: ['typescript', 'jsx'] }, beforeCompile: (c) => c.trim(), afterCompile: (c) => c, onError: (e) => console.error('Execution error:', e) } );
Remove legacy webpack-md-loader
@react-code-view/core)parseHTML utility: Native markdown parser that detects <!--start-code--> and <!--end-code--> markers@react-code-view/react)CodeViewInternal for proper hooks usage@react-code-view/unplugin)useNativeParser: true (default) generates CodeView components.md module types includedreact-code-view: 3.0.0@react-code-view/react: 3.0.0@react-code-view/core: 3.0.0@react-code-view/unplugin: 3.0.0Full Changelog: 2.3.1...2.4.0
Full Changelog: 2.2.1...2.3.0
Full Changelog: 2.2.0...2.2.1
Full Changelog: 2.1.0...2.2.0