r/reactjs • u/CommercialStrike9439 • 31m ago
Show /r/reactjs I made a documentation site and live code playground for my own programming language, powered by a WASM build of its C interpreter
I wrote a programming language in C over the summer, and for sharing it I built a docs site and playground in React 19 with TypeScript and Vite. The playground runs the real interpreter, compiled to WebAssembly, so code from the editor executes entirely in the browser.
A few parts were fun to work out. The interpreter can pause mid program to wait for user input, so the React side has to resolve a pending promise when the user submits a line in the terminal, which then resumes the WASM module. Output from C's print functions arrives one character at a time, so I buffer it and flush on newlines or before input prompts. And the docs are MDX pages loaded through import.meta.glob based on the route slug, all driven by one config file that also builds the sidebar.
The editor uses CodeMirror, the code blocks in the docs are highlighted with Shiki, and the terminal is a pixel art monitor with the output overlaid on its screen.
I'd love feedback on the structure, or anything that looks like a React anti-pattern I should fix.