Next Monaco provides a familiar full-featured code editing experience without sacrificing time to first byte.
npm install next-monaco
import * as React from 'react'/** Buttons give users the ability to perform actions. */export function Button({children,onClick,}: {children: React.ReactNodeonClick: React.MouseEventHandler<HTMLButtonElement>}) {return <button onClick={onClick}>{children}</button>}
* {box-sizing: border-box;margin: 0;}
import * as React from 'react'import { Button } from './Button'import './index.css'export default function Index() {return <Button onClick={() => alert('Hello')}>Say Hello</Button>}
import { createMonacoPlugin } from 'next-monaco/plugin'const withMonaco = createMonacoPlugin({theme: 'theme.json',types: ['next-monaco'],})export default withMonaco({experimental: {appDir: true,},})
import { Editor } from 'next-monaco'export default function App() {return (<EditorfileName="index.tsx"value={`import { React } from 'react'`}/>)}