return in the snippet.
React.createElement in React. Otherwise, Asteroid has the original
$run function, which provides the only way to add a React component to the preview. I won't go into React or JSX itself, but if you want to display HTML in the preview anyway, you can do so by writing the following.
$run(() => (<h1>Hello Asteroid</h1>))
It's hard to prepare a magical feature from scratch, but Asteroid has the feature to load external libraries written in ES Module (ESM) format, such as jQuery, Lodash, Three.js… anything that supports ESM format can be loaded by specifying the URL where the library is located! However, once interpreted, the source code can literally run anything in your browser, so depending on what you read, it can cause serious security issues. Check the contents of the library and do not enter unreliable libraries or URLs.
You can also find ESM format libraries on such as Pika CDN, for reference.
Asteroid supports a format called MDX for the output of projects that you create. This format is like a combination of Markdown and JSX.
Try it now