Skip to main content

CodeSandbox button

Adds a button under a code snippet to open/create a CodeSandbox project. (This button is hidden on mobile)

```js codesandbox
console.log('hello');
```
http://localhost:3000
console.log('hello');

Multiple files

Use code tabs to create sandboxes with multiple files.

Templates

By default, rise4fun will use an empty node.js template. You can provide additional named templates.

```tsx codesandbox=react
export default () => null;
```
http://localhost:3000
export default () => null;

The react template is configured in your docusaurus.config.js file using the same format as described in the CodeSandbox API.

./docusaurus.config.js
const config = configure({
...
}, {
codeSandbox: {
defaultTemplate: "react",
templates: {
react: {
files: {
"package.json": {
content: {
name: "react",
...
},
},
"sandbox.config.json": {
content: {
template: "node",
view: "terminal",
container: {
node: "18",
},
},
},
},
},
},
},
})