Installation

To use the quarto-live extension in your own documents, run the following command in a terminal with a Quarto project as the working directory:

Terminal
quarto add r-wasm/quarto-live

Once installed, the extension can be used with Quarto documents within this project.

Usage

First set the format for your Quarto document as a live variant in the YAML header:

---
format: live-html
---

The default rendering engine used by Quarto is jupyter, requiring a Python installation. If you’d prefer to avoid Python you can also explicitly select the knitr engine in the document’s YAML header:

---
format: live-html
engine: knitr
---

Next, after the YAML header but before your content, include setup code for the knitr engine using a relative path:

---
format: live-html
engine: knitr
---

{{< include ./_extensions/r-wasm/live/_knitr.qmd >}}
Note

Including _knitr.qmd is not strictly required if you are using the jupyter rendering engine. It is a temporary requirement for the knitr engine and will be removed in a future release of quarto-live.

Finally, place R code within a webr code blocks and python code within pyodide code blocks:

example_r.qmd
---
title: R Example
engine: knitr
format: live-html
---

{{< include ./_extensions/r-wasm/live/_knitr.qmd >}}

```{webr}
for (x in 1:5) {
  print(x ** 2)
}
```
example_python.qmd
---
title: Python Example
format: live-html
---

```{pyodide}
for x in range(5):
  print(x ** 2)
```