Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

docs: WebAssembly Notebooks, Publishing to the Web (#3389)

Akshay Agrawal5025a89a55dc
diff --git a/docs/guides/exporting.md b/docs/guides/exporting.md
index 358733940e..27fb5d7445 100644
--- a/docs/guides/exporting.md
+++ b/docs/guides/exporting.md
@@ -149,8 +149,12 @@ Options:
!!! note "Note"
- The exported file must be served over HTTP to function correctly - it cannot be opened directly from the filesystem (file://).
- Your server must also serve the assets in the `assets` directory, next to the HTML file. For this reason, we recommend using the online playground if possible: <https://marimo.app>.
+ The exported file must be served over HTTP to function correctly - it
+ cannot be opened directly from the filesystem (`file://`). Your server must
+ also serve the assets in the `assets` directory, next to the HTML file. For
+ a simpler publishing experience, publish to [GitHub
+ Pages](publishing/github_pages.md) or use the [online
+ playground](publishing/playground.md).
### Testing the export
@@ -161,51 +165,12 @@ cd path/to/output_dir
python -m http.server
```
-### Deploying to GitHub Pages
+### Publishing to GitHub Pages
-/// admonition | Template repository
- type: tip
+After exporting your notebook to WASM HTML, you can publish it to
+[GitHub Pages](https://pages.github.com/) for free. See our [guide on
+GitHub Pages](publishing/github_pages.md) to learn more.
-You can fork our [template repository](https://github.com/marimo-team/marimo-gh-pages-template) for deploying multiple notebooks to GitHub Pages. Once you have forked the repository, add your notebooks to the `notebooks`/`apps` directory.
-///
-
-You can deploy your WebAssembly marimo notebook to GitHub Pages using the following GitHub Actions workflow:
-
-```yaml
-jobs:
- build:
- runs-on: ubuntu-latest
-
- steps:
- # ... checkout and install dependencies
-
- - name: 📄 Export notebook
- run: |
- marimo export html-wasm notebook.py -o path/to/output --mode run
-
- - name: 📦 Upload Pages Artifact
- uses: actions/upload-pages-artifact@v3
- with:
- path: path/to/output
-
- deploy:
- needs: build
- runs-on: ubuntu-latest
- environment:
- name: github-pages
- url: ${{ steps.deployment.outputs.page_url }}
-
- permissions:
- pages: write
- id-token: write
-
- steps:
- - name: 🌐 Deploy to GitHub Pages
- id: deployment
- uses: actions/deploy-pages@v4
- with:
- artifact_name: github-pages
-```
### Exporting multiple notebooks
diff --git a/docs/guides/index.md b/docs/guides/index.md
index f73e0a91d3..0383e35670 100644
--- a/docs/guides/index.md
+++ b/docs/guides/index.md
@@ -7,24 +7,25 @@ These guides cover marimo's core concepts.
Prefer a hands-on learning experience? marimo comes packaged with interactive
tutorials that you can launch with `marimo tutorial` at the command line.
-| Guide | Description |
-| :--------------------------------------------------- | :----------------------------------------------------------- |
-| [Reactive execution](reactivity.md) | Understanding how marimo runs cells |
-| [Interactive elements](interactivity.md) | Using interactive UI elements |
-| [Visualizing outputs](outputs.md) | Creating markdown, plots, and other visual outputs |
-| [Migrating from Jupyter](coming_from/jupyter.md) | Tips for transitioning from Jupyter |
-| [Expensive notebooks](expensive_notebooks.md) | Tips for working with expensive notebooks |
-| [Working with data](working_with_data/index.md) | Using SQL cells, no-code dataframe tools, and reactive plots |
-| [Apps](apps.md) | Running notebooks as apps |
-| [Scripts](scripts.md) | Running notebooks as scripts |
-| [Tests](testing/index.md) | Running unit tests in notebooks |
-| [Export to HTML and other formats](exporting.md) | Exporting notebooks to HTML and flat scripts |
-| [Run notebooks with WebAssembly](wasm.md) | Create notebooks in our online playground |
-| [Deploying](deploying/index.md) | Deploying marimo notebooks and apps |
-| [Editor Features](editor_features/index.md) | View variables, dataframe schemas, docstrings, and more |
-| [Configuration](configuration/index.md) | Configure various settings |
-| [Coming from other tools](coming_from/index.md) | Transitioning from Jupyter and other tools |
-| [Extending marimo](integrating_with_marimo/index.md) | Rich displays of objects, custom UI plugins |
-| [State management](state.md) | Advanced: mutable reactive state |
-| [Best practices](best_practices.md) | Best practices to help you get the most out of marimo |
-| [Troubleshooting](troubleshooting.md) | Troubleshooting notebooks |
+| Guide | Description |
+| :--------------------------------------------------- | :--------------------------------------------------------- |
+| [Running cells](reactivity.md) | Understanding how marimo runs cells |
+| [Interactive elements](interactivity.md) | Using interactive UI elements |
+| [Visualizing outputs](outputs.md) | Creating markdown, plots, and other visual outputs |
+| [Migrating from Jupyter](coming_from/jupyter.md) | Tips for transitioning from Jupyter |
+| [Expensive notebooks](expensive_notebooks.md) | Tips for working with expensive notebooks |
+| [Working with data](working_with_data/index.md) | Using SQL cells, no-code dataframe, and reactive plots |
+| [Apps](apps.md) | Running notebooks as apps |
+| [Scripts](scripts.md) | Running notebooks as scripts |
+| [Tests](testing/index.md) | Running unit tests in notebooks |
+| [Export notebooks](exporting.md) | Exporting notebooks to HTML, ipynb, flat scripts, and more |
+| [Publish to the web](publishing/index.md) | Edit and publish notebooks on the web |
+| [Run notebooks with WebAssembly](wasm.md) | Create notebooks in our online playground |
+| [Deploying](deploying/index.md) | Deploying marimo notebooks and apps |
+| [Editor Features](editor_features/index.md) | View variables, dataframe schemas, docstrings, and more |
+| [Configuration](configuration/index.md) | Configure various settings |
+| [Coming from other tools](coming_from/index.md) | Transitioning from Jupyter and other tools |
+| [Extending marimo](integrating_with_marimo/index.md) | Rich displays of objects, custom UI plugins |
+| [State management](state.md) | Advanced: mutable reactive state |
+| [Best practices](best_practices.md) | Best practices to help you get the most out of marimo |
+| [Troubleshooting](troubleshooting.md) | Troubleshooting notebooks |
diff --git a/docs/guides/interactivity.md b/docs/guides/interactivity.md
index 104915ae57..20986ec280 100644
--- a/docs/guides/interactivity.md
+++ b/docs/guides/interactivity.md
@@ -1,7 +1,7 @@
# Interactive elements
One of marimo's most powerful features is its first-class support for
-interactive, stateful user interface (UI) elements, or "widgets": create them using
+interactive user interface (UI) elements, or "widgets", created using
[`marimo.ui`](../api/inputs/index.md). **Interacting with a UI element bound to a
global variable automatically runs all cells that reference it.**
@@ -11,9 +11,14 @@ global variable automatically runs all cells that reference it.**
</figure>
</div>
+!!! example "Examples"
+ See the [API reference](http://127.0.0.1:8000/api/inputs/) or our [GitHub
+ repo](https://github.com/marimo-team/marimo/tree/main/examples/ui) for
+ bite-sized examples on using input elements.
+
## How interactions run cells
-Every UI element you make using `marimo.ui` has a value, accessible via its
+Every UI element you make using [`marimo.ui`](../api/inputs/index.md) has a value, accessible via its
`value` attribute. When you interact with a UI element bound to a global
variable, its value is sent back to Python. A single rule determines what
happens next:
@@ -84,5 +89,5 @@ value on form submission.
## Building custom UI elements using our plugin API
You can build your own reactive and interactive UI elements using
-[anywidget](https://github.com/manzt/anywidget)! See [our docs on
+[anywidget](https://github.com/manzt/anywidget). See [our docs on
building custom UI elements](../guides/integrating_with_marimo/custom_ui_plugins.md) to learn more.
diff --git a/docs/guides/publishing/community_cloud/index.md b/docs/guides/publishing/community_cloud/index.md
new file mode 100644
index 0000000000..5a307fdeb0
--- /dev/null
+++ b/docs/guides/publishing/community_cloud/index.md
@@ -0,0 +1,16 @@
+# Community Cloud
+
+Our [Community Cloud](https://marimo.io/dashboard) is a free workspace
+for creating, saving, and sharing marimo notebooks. Unlike the
+[Playground](../playground.md), the Community Cloud requires a login. In
+return, it lets you save noteoboks, share them using email-based authorization,
+and upload a limited amount of data.
+
+!!! note "WebAssembly notebooks only"
+
+ Currently, the Community Cloud only allows the creation of [WebAssembly
+ notebooks](../../wasm.md). These are easy to share and embed in other
+ web pages, but have some limitations in packages and performance.
+
+Note: unlike our other publishing options, it is not possible to embed
+editable Community Cloud notebooks in other web pages.
diff --git a/docs/guides/publishing/deploy.md b/docs/guides/publishing/deploy.md
new file mode 100644
index 0000000000..e974eae2cd
--- /dev/null
+++ b/docs/guides/publishing/deploy.md
@@ -0,0 +1,9 @@
+# Deploy on backends
+
+If you cannot use WebAssembly notebooks, you can deploy marimo notebooks via a
+traditional client-server model.
+
+Both the edit server can be deployed as well as individual notebooks (as
+readonly apps).
+
+Learn more in our [Deployment Guide](../deploying/index.md).
diff --git a/docs/guides/publishing/embedding.md b/docs/guides/publishing/embedding.md
new file mode 100644
index 0000000000..1b12e0f3b0
--- /dev/null
+++ b/docs/guides/publishing/embedding.md
@@ -0,0 +1,13 @@
+# Embedding
+
+There are various ways to embed marimo notebooks in other web pages, such
+as web documentation, educational platforms, or static sites in general. Here
+are two ways:
+
+* Host on [GitHub Pages](github_pages.md) or [self-host WASM HTML](self_host_wasm.md),
+ and `<iframe>` the published notebook.
+* `<iframe>` a playground notebook, and [customize the embedding](playground.md#embedding-in-other-web-pages) with query params.
+ (This is what we do throughout docs.marimo.io.)
+
+We plan to provide more turn-key solutions for static site generation with
+marimo notebooks in the future.
diff --git a/docs/guides/publishing/github_pages.md b/docs/guides/publishing/github_pages.md
new file mode 100644
index 0000000000..d81576bbef
--- /dev/null
+++ b/docs/guides/publishing/github_pages.md
@@ -0,0 +1,79 @@
+# Publish to GitHub Pages
+
+You can publish executable notebooks to [GitHub Pages](https://pages.github.com/)
+for free, after exporting your notebook to a WebAssembly notebook.
+
+## Export to WASM-powered HTML
+
+Export your notebook to a self-contained HTML file that runs using [WebAssembly](../wasm.md):
+
+/// tab | Export as a readonly app
+
+```bash
+marimo export html-wasm notebook.py -o output_dir --mode run
+```
+
+///
+
+/// tab | Export as an editable notebook
+
+```bash
+marimo export html-wasm notebook.py -o output_dir --mode edit
+```
+
+///
+
+See our [exporting guide](../exporting.md#export-to-wasm-powered-html) for
+the full documentation.
+
+## Publish using GitHub Actions
+
+/// tip | Template repository
+
+Fork our [template repository](https://github.com/marimo-team/marimo-gh-pages-template) for deploying multiple notebooks to GitHub Pages. Once you have forked the repository, add your notebooks to the `notebooks` or `apps` directories,
+for editable or readonly respectively.
+///
+
+Publish to GitHub Pages using the following GitHub Actions workflow,
+which will republish your notebook on git push.
+
+```yaml
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ # ... checkout and install dependencies
+
+ - name: 📄 Export notebook
+ run: |
+ marimo export html-wasm notebook.py -o path/to/output --mode run
+
+ - name: 📦 Upload Pages Artifact
+ uses: actions/upload-pages-artifact@v3
+ with:
+ path: path/to/output
+
+ deploy:
+ needs: build
+ runs-on: ubuntu-latest
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+
+ permissions:
+ pages: write
+ id-token: write
+
+ steps:
+ - name: 🌐 Deploy to GitHub Pages
+ id: deployment
+ uses: actions/deploy-pages@v4
+ with:
+ artifact_name: github-pages
+```
+
+## Publish manually
+
+You can also publish an exported notebook manually, through your repository
+settings. Read [GitHub's documentation](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) to learn more.
diff --git a/docs/guides/publishing/index.md b/docs/guides/publishing/index.md
new file mode 100644
index 0000000000..147549fc06
--- /dev/null
+++ b/docs/guides/publishing/index.md
@@ -0,0 +1,21 @@
+# Publishing notebooks to the web
+
+You can publish marimo notebooks to the web as interactive editable notebooks,
+readonly web apps, or [static documents](../exporting.md).
+
+Thanks to [WebAssembly](../wasm.md), you can even share executable
+notebooks on GitHub Pages or other static sites without paying for backend
+infrastrcture. This makes it easy to share your work with colleagues, embed
+executable notebooks in web documentation or educational websites, and more.
+
+This guide provides an overview of the various ways to publish marimo notebooks.
+
+| Guide | Description |
+| ----------------------------------------------------- | ------------------------------------------------------------ |
+| [Embedding](embedding.md) | An overview of embedding notebooks in other sites |
+| [GitHub Pages](github_pages.md) | Publishing interactive notebooks on GitHub Pages |
+| [Online playground](playground.md) | Sharing notebook links using our online playground |
+| [Community Cloud](community_cloud/index.md) | Save notebooks to our free Community Cloud |
+| [Self-host WebAssembly notebooks](self_host_wasm.md) | Self-hosting interactive WebAssembly (HTML export) notebooks |
+| [View notebooks on GitHub](view_outputs_on_github.md) | Viewing notebook outputs on GitHub |
+| [Deploy on a backend](deploy.md) | Deploying notebooks on backends |
diff --git a/docs/guides/publishing/playground.md b/docs/guides/publishing/playground.md
new file mode 100644
index 0000000000..5bf66944da
--- /dev/null
+++ b/docs/guides/publishing/playground.md
@@ -0,0 +1,165 @@
+# Online playground
+
+Our [online playground](https://marimo.app) lets you
+create and share marimo notebooks for free, without creating an account.
+
+Playground notebooks are great for embedding in other web pages — all the
+notebooks embedding in marimo's own docs are playground notebooks. They
+are also great for sharing via links.
+
+**Try our playground!** Just navigate to
+[https://marimo.new](https://marimo.new).
+
+!!! note "WebAssembly notebooks only"
+
+ Currently, the online playground only allows the creation of [WebAssembly
+ notebooks](../wasm.md). These are easy to share and embed in other
+ web pages, but have some limitations in packages and performance.
+
+_The notebook embedded below is a playground notebook!_
+
+<iframe src="https://marimo.app/l/upciwv?embed=true" width="100%" height=400 frameBorder="0"></iframe>
+
+## Creating and sharing WASM notebooks
+
+WASM notebooks run at [marimo.app](https://marimo.app).
+
+### New notebooks
+
+To create a new playground notebook, visit <https://marimo.new>.
+
+Think of [marimo.new](https://marimo.new) as a
+scratchpad for experimenting with code, data, and models and for prototyping
+tools, available to you at all times and on all devices.
+
+!!! tip "Saving playground notebooks"
+
+ When you save a WASM notebook, a copy of your code is saved to your
+ web browser's local storage. When you return to
+ [marimo.app](https://marimo.app), the last notebook you worked on will be
+ re-opened. You can also click a button to save your notebook to
+ the [Community Cloud](community_cloud/index.md).
+
+### Share via links
+
+At [marimo.app](https://marimo.app), save your notebook and then click the
+`Create permalink` button to generate a shareable permalink to your
+notebook.
+
+Please be aware that marimo permalinks are publicly accessible.
+
+### Creating playground notebooks from GitHub
+
+Use the "New > Open from URL" menu item to paste a link to a GitHub notebook.
+
+### Creating playground notebooks from local notebooks
+
+In the marimo editor's notebook action menu, use `Share > Create WebAssembly
+link` to get a `marimo.app/...` URL representing your notebook:
+
+<div align="center">
+<figure>
+<img src="/_static/share-wasm-link.gif"/>
+</figure>
+</div>
+
+WASM notebooks come with common Python packages installed, but you may need to
+[install additional packages using micropip](../wasm.md#supported-packages).
+
+The obtained URL encodes your notebook code as a parameter, so it can be
+quite long. If you want a URL that's easier to share, you can [create a
+shareable permalink](#share-via-links).
+
+## Configuration
+
+Your `marimo.app` URLs can be configured using the following parameters.
+
+### Read-only mode
+
+To view a notebook in read-only mode, with
+code cells locked, append `&mode=read` to your URL's list of query parameters
+(or `?mode=read` if your URL doesn't have a query string).
+
+Example:
+
+- `https://marimo.app/l/83qamt?mode=read`
+
+### Hide header for embedding
+
+To hide the `marimo.app` header, append `&embed=true` to your URL's list of query
+parameters (or `?embed=true` if your URL doesn't have a query string).
+
+Example:
+
+- `https://marimo.app/l/83qamt?embed=true`
+- `https://marimo.app/l/83qamt?mode=read&embed=true`
+
+See the [section on embedding](#embedding-in-other-web-pages) for examples of
+how to embed marimo notebooks in your own webpages.
+
+### Excluding code
+
+By default, WASM notebooks expose your Python code to viewers. If you've
+enabled read-only mode, you can exclude code with
+`&include-code=false`. If you want to include code but have it be hidden
+by default, use the parameter `&show-code=false`.
+
+A sufficiently determined user would still be able
+to obtain your code, so **don't** think of this as a security feature; instead,
+think of it as an aesthetic or practical choice.
+
+## Embedding in other web pages
+
+WASM notebooks can be embedded into other webpages using the HTML `<iframe>`
+tag.
+
+### Embedding a blank notebook
+
+Use the following snippet to embed a blank marimo notebook into your web page,
+providing your users with an interactive code playground.
+
+```html
+<iframe
+ src="https://marimo.app/l/aojjhb?embed=true"
+ width="100%"
+ height="300"
+ frameborder="0"
+></iframe>
+```
+
+<iframe src="https://marimo.app/l/aojjhb?embed=true" width="100%" height="300" class="demo" frameBorder="0"></iframe>
+
+### Embedding an existing notebook
+
+To embed existing marimo notebooks into a webpage, first, [obtain a
+URL to your notebook](#creating-and-sharing-wasm-notebooks), then put it in an iframe.
+
+```html
+<iframe
+ src="https://marimo.app/l/c7h6pz?embed=true"
+ width="100%"
+ height="300"
+ frameborder="0"
+></iframe>
+```
+
+<iframe src="https://marimo.app/l/c7h6pz?embed=true" width="100%" height="600" class="demo" frameBorder="0"></iframe>
+
+After obtaining a URL to your
+notebook,
+
+### Embedding an existing notebook in read-only mode
+
+You can optionally render embedded notebooks in read-only mode by appending
+`&mode=read` to your URL.
+
+```html
+<iframe
+ src="https://marimo.app/l/c7h6pz?mode=read&embed=true"
+ width="100%"
+ height="300"
+ frameborder="0"
+></iframe>
+```
+
+<iframe src="https://marimo.app/l/c7h6pz?mode=read&embed=true" width="100%" height="600" class="demo" frameBorder="0"></iframe>
diff --git a/docs/guides/publishing/self_host_wasm.md b/docs/guides/publishing/self_host_wasm.md
new file mode 100644
index 0000000000..b2efdaec65
--- /dev/null
+++ b/docs/guides/publishing/self_host_wasm.md
@@ -0,0 +1,10 @@
+# Self-host WebAssembly notebooks
+
+As an alternative to [GitHub Pages](github_pages.md), it is possible to self-host
+exported [WebAssembly notebooks](../wasm.md):
+
+- [Export to WASM HTML](../exporting.md#export-to-wasm-powered-html).
+- Serve the exported file over HTTP.
+- Serve the assets in the `assets` directory, next to the HTML file.
+- Possibly configure your web server to support serving `application/wasm/`
+ files with the correct headers.
diff --git a/docs/guides/publishing/view_outputs_on_github.md b/docs/guides/publishing/view_outputs_on_github.md
new file mode 100644
index 0000000000..0939a351f1
--- /dev/null
+++ b/docs/guides/publishing/view_outputs_on_github.md
@@ -0,0 +1,15 @@
+# View Outputs on GitHub
+
+marimo notebooks are stored as pure Python files, in order to
+work with Git versioning and the broader Python ecosystem. However, this means
+that unlike Jupyter notebooks, by default you cannot see marimo notebook
+outputs on GitHub.
+
+If you would like to make outputs viewable on GitHub, you can configure
+any given marimo notebook to automatically snapshot its outputs to an
+`ipynb` file. The snapshot will be saved to a `__marimo__` directory
+in the same folder where the notebook lives, which you can then
+push to GitHub.
+
+Enable snapshotting in the notebook settings menu, using the gear icon in the
+top right of any notebook.
diff --git a/docs/guides/wasm.md b/docs/guides/wasm.md
index 73902de3fe..f276eddf4e 100644
--- a/docs/guides/wasm.md
+++ b/docs/guides/wasm.md
@@ -1,91 +1,78 @@
-# Online playground
+# WebAssembly Notebooks
-We've built an [online playground](https://marimo.app) that lets you
-run marimo **entirely in the browser** -- no backend required!
+marimo lets you execute notebooks _entirely in the browser_,
+without a backend executing Python. marimo notebooks that
+run entirely in the browser are called WebAssembly notebooks, or WASM notebooks
+for short.
-marimo notebooks that run entirely in the browser are called **WebAssembly
-notebooks**, or **WASM notebooks** for short.
+!!! tip "Try our online playground"
-In contrast to marimo notebooks that you create with the CLI, WASM notebooks
-run without a web server and Python process; instead, the web browser executes
-your Python code. For this reason, WASM makes it extremely easy to
-share marimo notebooks, and makes it possible to tinker with notebooks without
-having to install Python on your machine.
+ To create your first WASM notebook, try our online playground
+ at [marimo.new](https://marimo.new). Read the [playground
+ docs](publishing/playground.md) to learn more.
-**Try our playground!** Just navigate to
-[https://marimo.new](https://marimo.new).
+WASM notebooks have three benefits compared to notebooks hosted using a
+traditional client-server model. WASM notebooks:
-!!! note "WASM?"
+1. eliminate the need to install Python, making scientific computing accessible;
+2. eliminate the cost and complexity of deploying backend infrastructure, making it easy to share notebooks;
+3. eliminate network requests to a remote Python runner, making development feel snappy.
- marimo-in-the-browser is powered by a technology called
- [WebAssembly](https://webassembly.org/), or "WASM" for short. Hence the
- name "WASM notebook".
+!!! question "When should I use WASM notebooks?"
-!!! note "When should I use WASM notebooks?"
+ WASM notebooks are excellent for sharing your work, quickly experimenting
+ with code and models, doing lightweight data exploration, authoring blog
+ posts, tutorials, and educational materials, and even building tools. For
+ notebooks that do heavy computation, [use marimo
+ locally](http://127.0.0.1:8000/getting_started/) or on a backend.
- WASM notebooks are excellent for sharing your work, quickly experimenting with
- code and models, doing lightweight data exploration, authoring blog posts,
- tutorials, and educational materials, and even building tools. They are
- not well-suited for notebooks that do heavy computation.
+**Try it!** Try editing the below notebook (your browser, not a backend server, is executing it!)
-!!! warning "Issues?"
+<iframe src="https://marimo.app/l/upciwv?embed=true" width="100%" height=400 frameBorder="0"></iframe>
- WASM notebooks are a new feature. If you run into
- problems, please open a [GitHub issue](https://github.com/marimo-team/marimo/issues).
+_This feature is powered by [Pyodide](https://pyodide.org), a port
+of Python to WebAssembly that enables browsers to run Python code._
-## Creating and sharing WASM notebooks
+## Creating WASM notebooks
-WASM notebooks run at [marimo.app](https://marimo.app).
+marimo provides three ways to create and share WASM notebooks:
-### Creating new notebooks
+1. [Export to WASM HTML](exporting.md#export-to-wasm-powered-html),
+ which you can host on GitHub Pages or self-host. This is great for
+ publishing companion notebooks for research papers that are automatically
+ updated on Git push, or for embedding interactive notebooks as part of other
+ websites.
+2. The [online playground](publishing/playground.md), which lets you
+ create one-off notebooks and share via links, no login required. The
+ playground is also great for embedding editable notebooks in
+ documentation.
+3. The [Community Cloud](publishing/community_cloud/index.md), which
+ lets you save a collection of notebook to a workspace (for free!) and share
+ publicly or privately with sensible URLs.
-To create a new WASM notebook, just visit
-[marimo.new](https://marimo.new).
+### From GitHub
-Think of [marimo.new](https://marimo.new) as your own personal
-scratchpad for experimenting with code, data, and models and for prototyping
-tools, available to you at all times and on all devices.
+marimo provides three ways to share notebooks stored on GitHub as WASM notebooks:
-!!! tip "Saving WASM notebooks"
+1. Automatically publish to GitHub Pages on git push with [our GitHub action](publishing/github_pages.md).
+2. Load a notebook by URL into the online playground (New > Open from URL ...)
+3. Load a notebook from GitHub in the [Community Cloud](publishing/community_cloud/index.md).
- When you save a WASM notebook, a copy of your code is saved to your
- web browser's local storage. When you return to [marimo.app](https://marimo.app),
- the last notebook you worked on will be re-opened.
+## Packages
-### Creating shareable permalinks
+!!! tip "Rendering performance"
-At [marimo.app](https://marimo.app), save your notebook and then click the
-`Create permalink` button to generate a shareable permalink to your
-notebook.
-
-Please be aware that marimo permalinks are publicly accessible.
-
-### Creating WASM notebooks from local notebooks
-
-In the marimo editor's notebook action menu, use `Share > Create WebAssembly
-link` to get a `marimo.app/...` URL representing your notebook:
-
-<div align="center">
-<figure>
-<img src="/_static/share-wasm-link.gif"/>
-</figure>
-</div>
-
-WASM notebooks come with common Python packages installed, but you may need to
-[install additional packages using micropip](#installing-packages).
-
-The obtained URL encodes your notebook code as a parameter, so it can be
-quite long. If you want a URL that's easier to share, you can [create a
-shareable permalink](#creating-shareable-permalinks).
-
-## Installing packages
+ To make sure markdown and other elements render quickly: make sure to put
+ `import marimo as mo` in its own cell, with no other lines of code.
WASM notebooks come with many packages pre-installed, including
NumPy, SciPy, scikit-learn, pandas, and matplotlib; see [Pyodide's
documentation](https://pyodide.org/en/stable/usage/packages-in-pyodide.html)
for a full list.
-To install other packages, use `micropip`:
+If you attempt to import a package that is not installed, marimo will
+attempt to automatically install it for you. To manually install packages, use
+[`micropip`](https://micropip.pyodide.org/en/stable/project/usage.html):
In one cell, import micropip:
@@ -93,125 +80,73 @@ In one cell, import micropip:
import micropip
```
-In the next one, install packages:
+In the next cell, install packages:
```python
await micropip.install("plotly")
import plotly
```
-**Try it!** A WASM notebook is embedded below. Try installing a package.
-
-<iframe src="https://marimo.app/l/wvz76s?embed=true" width="100%" height=300 class="demo" frameBorder="0">
-</iframe>
-
-## Configuration
-
-Your `marimo.app` URLs can be configured using the following parameters.
-
-### Read-only mode
-
-To view a notebook in read-only mode, with
-code cells locked, append `&mode=read` to your URL's list of query parameters
-(or `?mode=read` if your URL doesn't have a query string).
-
-Example:
-
-- `https://marimo.app/l/83qamt?mode=read`
-
-### Embed
-
-To hide the `marimo.app` header, append `&embed=true` to your URL's list of query
-parameters (or `?embed=true` if your URL doesn't have a query string).
-
-Example:
+### Supported packages
-- `https://marimo.app/l/83qamt?embed=true`
-- `https://marimo.app/l/83qamt?mode=read&embed=true`
-
-See the [section on embedding](#embedding) for examples of how to embed marimo
-notebooks in your own webpages.
-
-### Excluding code
-
-By default, WASM notebooks expose your Python code to viewers. If you've
-enabled read-only mode, you can exclude code with
-`&include-code=false`. If you want to include code but have it be hidden
-by default, use the parameter `&show-code=false`.
-
-A sufficiently determined user would still be able
-to obtain your code, so **don't** think of this as a security feature; instead,
-think of it as an aesthetic or practical choice.
-
-## Embedding
-
-WASM notebooks can be embedded into other webpages using the HTML `<iframe>`
-tag.
+All packages with pure Python wheels on PyPI are supported, as well as
+additional packages like NumPy, SciPy, scikit-learn, duckdb, polars, and more.
+For a full list of supported packages, see [Pyodide's
+documentation on supported packages.](https://pyodide.org/en/stable/usage/packages-in-pyodide.html)
-### Embedding a blank notebook
+If you want a package to be supported, consider [filing an issue](https://github.com/pyodide/pyodide/issues/new?assignees=&labels=new+package+request&projects=&template=package_request.md&title=).
-Use the following snippet to embed a blank marimo notebook into your web page,
-providing your users with an interactive code playground.
-```html
-<iframe
- src="https://marimo.app/l/aojjhb?embed=true"
- width="100%"
- height="300"
- frameborder="0"
-></iframe>
-```
+## Including data
-<iframe src="https://marimo.app/l/aojjhb?embed=true" width="100%" height="300" class="demo" frameBorder="0"></iframe>
+**For notebooks exported to WASM HTML.**
+To include data files in notebooks [exported to WASM
+HTML](exporting.md#export-to-wasm-powered-html), place them
+in a `public/` folder in the same directory as your notebook. When you
+export to WASM HTML, the public folder will be copied to the export directory.
-### Embedding an existing notebook
+In order to access data both locally and when an exported notebook runs via
+WebAssembly (e.g., hosted on GitHub Pages), use
+[`mo.notebook_location()`][marimo.notebook_location] to construct the path to
+your data:
-To embed existing marimo notebooks into a webpage, first, [obtain a
-URL to your notebook](#creating-and-sharing-wasm-notebooks), then put it in an iframe.
+```python
+import polars as pl
-```html
-<iframe
- src="https://marimo.app/l/c7h6pz?embed=true"
- width="100%"
- height="300"
- frameborder="0"
-></iframe>
+path_to_csv = mo.notebook_location() / "public" / "data.csv"
+df = pl.read_csv(path_to_csv)
+df.head()
```
-<iframe src="https://marimo.app/l/c7h6pz?embed=true" width="100%" height="600" class="demo" frameBorder="0"></iframe>
-
-After obtaining a URL to your
-notebook,
-
-### Embedding an existing notebook in read-only mode
-
-You can optionally render embedded notebooks in read-only mode by appending
-`&mode=read` to your URL.
+**Fetching data files from the web.**
+Instead of bundling data files with your notebook, you can host data files on
+the web and fetch them in your notebook. Depending on where your files are
+hosted, you may need to use a CORS Proxy; see the [Pyodide
+documentation](https://pyodide.org/en/stable/usage/loading-packages.html#installing-wheels-from-arbitrary-urls)
+for more details.
-```html
-<iframe
- src="https://marimo.app/l/c7h6pz?mode=read&embed=true"
- width="100%"
- height="300"
- frameborder="0"
-></iframe>
-```
+**Playground notebooks.** When opening [playground notebook](publishing/playground.md)
+from GitHub, the data files in the notebook directory are automatically
+downloaded and made available to your notebook.
-<iframe src="https://marimo.app/l/c7h6pz?mode=read&embed=true" width="100%" height="600" class="demo" frameBorder="0"></iframe>
+**Community Cloud notebooks.** Our free [Community
+Cloud](publishing/community_cloud/index.md) lets you upload a limited
+amount of data, and also lets you sync notebooks (and their data) from GitHub.
## Limitations
-While WASM notebooks let you get up and running with marimo instantly, they
-have some limitations.
-
-**Packages.** Not all packages are available in WASM notebooks; see [Pyodide's
-documentation on supported packages.](https://pyodide.org/en/stable/usage/packages-in-pyodide.html)
+While WASM notebooks let you share marimo notebooks seamlessly, they have some
+limitations.
-**PDB.** PDB is not currently supported. This may be fixed in the future.
+**PDB.** PDB is not currently supported.
**Threading and multi-processing.** WASM notebooks do not support multithreading
and multiprocessing. [This may be fixed in the future](https://github.com/pyodide/pyodide/issues/237).
+**Memory.** WASM notebooks have a memory limit of 2GB; this may be increased
+in the future. If memory consumption is an issue, try offloading memory-intensive
+computations to hosted APIs or precomputing expensive operations.
+
## Browser support
WASM notebooks are supported in the latest versions of Chrome, Firefox, Edge, and Safari.
diff --git a/docs/guides/working_with_data/sql.md b/docs/guides/working_with_data/sql.md
index 80b3f4be2b..f716487726 100644
--- a/docs/guides/working_with_data/sql.md
+++ b/docs/guides/working_with_data/sql.md
@@ -31,7 +31,7 @@ conda install -c conda-forge marimo duckdb polars
///
-!!! tip "Examples"
+!!! example "Examples"
For example notebooks, check out
[`examples/sql/` on GitHub](https://github.com/marimo-team/marimo/tree/main/examples/sql/).
diff --git a/docs/index.md b/docs/index.md
index 18f48c1dec..493b877456 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -57,7 +57,7 @@ reproducibility, maintainability, composability, and shareability.
- 🚀 **batteries-included:** replaces `jupyter`, `streamlit`, `jupytext`, `ipywidgets`, `papermill`, and more
- ⚡️ **reactive**: run a cell, and marimo reactively [runs all dependent cells](guides/reactivity.md) or <a href="#expensive-notebooks">marks them as stale</a>
- 🖐️ **interactive:** [bind sliders, tables, plots, and more](guides/interactivity.md) to Python — no callbacks required
-- 🔬 **reproducible:** [no hidden state](guides/reactivity.md#no-hidden-state), deterministic execution, [built-in package management](guides/editor_features/package_management.md)
+- 🔬 **reproducible:** [no hidden state](guides/reactivity.md), deterministic execution, [built-in package management](guides/editor_features/package_management.md)
- 🏃 **executable:** [execute as a Python script](guides/scripts.md), parameterized by CLI args
- 🧪 **testable:** [run your favorite test suite](guides/testing/index.md), verify your notebook's correctness
- 🛜 **shareable**: [deploy as an interactive web app](guides/apps.md) or [slides](guides/apps.md#slides-layout), [run in the browser via WASM](guides/wasm.md)
diff --git a/mkdocs.yml b/mkdocs.yml
index 1deb702af5..7122b18f91 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -78,23 +78,37 @@ nav:
- User Guide: guides/index.md
- Running cells: guides/reactivity.md
- Interactive elements: guides/interactivity.md
- - Visualizing outputs: guides/outputs.md
- - Migrating from Jupyter: guides/coming_from/jupyter.md
+ - Visualize outputs: guides/outputs.md
+ - Migrate from Jupyter: guides/coming_from/jupyter.md
- Expensive notebooks: guides/expensive_notebooks.md
- SQL, dataframes, and plots:
- SQL, dataframes, and plots: guides/working_with_data/index.md
- DataFrames: guides/working_with_data/dataframes.md
- SQL: guides/working_with_data/sql.md
- Plotting: guides/working_with_data/plotting.md
+ - Editor features:
+ - Editor features: guides/editor_features/index.md
+ - Editor overview: guides/editor_features/overview.md
+ - AI Completion: guides/editor_features/ai_completion.md
+ - Hotkeys: guides/editor_features/hotkeys.md
+ - Package Management: guides/editor_features/package_management.md
- Run notebooks as apps: guides/apps.md
- Run notebooks as scripts: guides/scripts.md
- - Testing notebooks:
+ - Test notebooks:
- Testing notebooks: guides/testing/index.md
- pytest: guides/testing/pytest.md
- doctest: guides/testing/doctest.md
- - Export to HTML and other formats: guides/exporting.md
- - Run notebooks with WebAssembly: guides/wasm.md
- - Deploy notebooks:
+ - Export to other formats: guides/exporting.md
+ - Publish to the web:
+ - Publish to the web: guides/publishing/index.md
+ - Embedding: guides/publishing/embedding.md
+ - GitHub Pages: guides/publishing/github_pages.md
+ - Online playground: guides/publishing/playground.md
+ - Community Cloud: guides/publishing/community_cloud/index.md
+ - Self-host WASM: guides/publishing/self_host_wasm.md
+ - View outputs on GitHub: guides/publishing/view_outputs_on_github.md
+ - Deploy a backend: guides/publishing/deploy.md
+ - Deployment:
- Deploy notebooks: guides/deploying/index.md
- Authentication: guides/deploying/authentication.md
- Docker: guides/deploying/deploying_docker.md
@@ -105,12 +119,7 @@ nav:
- nginx: guides/deploying/deploying_nginx.md
- Prebuilt containers: guides/deploying/prebuilt_containers.md
- Programmatic: guides/deploying/programmatically.md
- - Editor features:
- - Editor features: guides/editor_features/index.md
- - Editor overview: guides/editor_features/overview.md
- - AI Completion: guides/editor_features/ai_completion.md
- - Hotkeys: guides/editor_features/hotkeys.md
- - Package Management: guides/editor_features/package_management.md
+ - WebAssembly notebooks: guides/wasm.md
- Configuration:
- Configuration: guides/configuration/index.md
- Runtime configuration: guides/configuration/runtime_configuration.md
@@ -284,11 +293,8 @@ theme:
- search.suggest # search suggestions
- toc.follow # auto-scroll TOC
font:
- code:
- - Roboto Mono
- text:
- - Inter
- - Roboto
+ code: Fira Mono
+ text: PT Sans
logo: _static/marimo-logotype-horizontal.png
name: material
palette: